How to manage server-side errors?

I’m trying to process an action on server-side, like deleting a task, but if it returns an error (database timeout for example), I want to prevent the task from being deleted from Gantt. Something like:

var dp = gantt.createDataProcessor({
  url: "/api",
  mode: "JSON"

dp.attachEvent("onAfterUpdate", function(id, action, tid, response){
    // receive error message, displays to user and prevents changes in Gantt -- in this case, don't delete the task

How can I do that?

Hello Diego,
There is no built-in way to do that with the current Gantt API. But we have that in our wishlist.

Now, as a workaround, you can connect the Undo extension and use the gantt.undo() method if there is an error on the server-side:
Here is an example:

Another way is to reload the data from the server-side: