we are using SQL Anywhere and MobiLink

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

Alexander%20Ilg's gravatar image

Alexander Ilg
accept rate: 0%

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.

permanent link

answered 25 Mar '15, 14:04

Bill%20Somers's gravatar image

Bill Somers
accept rate: 36%

edited 25 Mar '15, 14:13

There is another option. You can use the modify_error_message script. See the documentation here.

permanent link

answered 25 Mar '15, 13:27

RussC_FromSAP's gravatar image

accept rate: 20%

As Bill answered, the modify_error_message script is only invoked for SQL errors. If a Java script causes a SQL error, it causes a SQLException in the Java script, not a SQL error visible to the MobiLink server.

(25 Mar '15, 14:38) Graham Hurst

Have you had a look at the following doc topics:

Basically, you will have to set the action_code value.

permanent link

answered 25 Mar '15, 11:53

Volker%20Barth's gravatar image

Volker Barth
accept rate: 32%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 25 Mar '15, 11:37

question was seen: 463 times

last updated: 25 Mar '15, 14:38