How to manage server-side errors?

Hello
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:
https://docs.dhtmlx.com/gantt/desktop__undo_redo.html
Here is an example:
https://snippet.dhtmlx.com/bd20b1603

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

gantt.clearAll();
gantt.load('URL');

Hello Diego,
The dev team added the feature that allows keeping the deleted tasks on the client-side until they are removed on the server:
https://docs.dhtmlx.com/gantt/whatsnew.html#x6629x80x6630x:~:text=The%20ability%20to%20delete%20items%20only%20after%20receiving%20confirmation%20from%20the%20backend%3A

createDataProcessor Gantt Docs.

You can see how it works in the following sample:
http://snippet.dhtmlx.com/5/6f8fa55b5