on 2015 Mar 25 11:37 AM
Hello,
we are using SQL Anywhere and MobiLink 16.0.0.2052.
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
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is another option. You can use the modify_error_message script. See the documentation here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you had a look at the following doc topics:
Basically, you will have to set the action_code value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
41 | |
15 | |
10 | |
9 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.