we are using SQL Anywhere and MobiLink 18.104.22.1682.
We wrote a Java based synchronization script for the prepare_download event. In our Java method we are doing some validation, which sometimes lead to Java Exception.
When this happens, we get a sync failed on the client. That is the behaviour that we would expect. However it would be more elegant to catch the exception instead and send a meaningful error message to the client and the user.
I checked the dcx side, but could not find something about forcefully letting a sync fail and sending error messages to the client. Any idea how this can be done?
Thanks and best regards, Alex
asked 25 Mar '15, 11:37
The modify_error_message script is invoked only for SQL errors, so it won't get triggered for Java exceptions.
On v12 and earlier you could return a SQL string from your Java script that will raise an error and then use the modify_error_message to change that message to what you want.
Alternatively, you could create table that you log the errors to. Then you can create a separate publication that you use to download the error if a sync fails. This would work on all version of the server. Edit: This has to be done on a connection returned by ServerContext.makeConnection(), since the connection returned by DBContext.getConnection will be rolled back when the prepare_for_download script fails.
This is a feature that customers and internal users have asked for, but I haven't had time to get around to fixing it. It's something that I would like to change, but I can't make any promises as to when or which versions.