error_handler event

Configure this event to indicate when a transmission fails or was not confirmed. For example, when a transmission fails, you can use this event to insert a row in an audit table or to send a push notification.

The following table details the parameters that can be captured using the error_handler event:

Script parameter Type Description
request_option (out) Integer

Controls what the Notifier does to the push request after the error handler returns. The output can be one of the following values:

  • 0: Perform default action based on the error code and log the error.
  • 1: Do nothing.
  • 2: Execute the request_delete event.
  • 3: Attempt to deliver to a secondary gateway.
error_code (in) Integer

Use one of the following values for the error code:

  • -1: The request timed out with confirmation of success.
  • -8: An error occurred during delivery attempt.
request_id (in) Integer Identifies the request.
gateway (in) Varchar Specifies the gateway associated with the push request.
address (in) Varchar Specifies the address associated with the push request.
subject (in) Varchar Specifies the subject associated with the push request.
content (in) Varchar Specifies the content associated with the push request.
Note

This event requires the use of a system procedure. You can not configure this event directly using Sybase Central. See MobiLink server settings for server-initiated synchronization.

See also
Example

In the following example, you create a table called CustomError and log errors to the table using a stored procedure called CustomErrorHandler. The output parameter Notifier_opcode is always 0, which means that default Notifier handling is used.

CREATE TABLE CustomError(
    error_code  integer,
    request_id  integer,
    gateway  varchar(255),
    address  varchar(255),
    subject  varchar(255),
    content  varchar(255),
    occurAt  timestamp not null default timestamp
);

CREATE PROCEDURE CustomErrorHandler(
    out @Notifier_opcode integer,
    in @error_code  integer,
    in @request_id  integer,
    in @gateway   varchar(255),
    in @address   varchar(255),
    in @subject   varchar(255),
    in @content   varchar(255)
)

BEGIN
    INSERT INTO CustomError( 
        error_code,
        request_id,
        gateway,
        address,
        subject,
        content)
    VALUES(
        @error_code,
        @request_id,
        @gateway,
        @address,
        @subject,
        @content
    );
    SET @Notifier_opcode = 0;
END

To use this ml_add_property system procedure with a SQL Anywhere consolidated database, run the following command:

call ml_add_property( 
    'SIS',
    'Notifier(myNotifier)',
    'error_handler',
    'call CustomErrorHandler(?, ?, ?, ?, ?, ?, ?)');

Alternatively, you can fire this event by adding the following line to a Notifier configuration file:

Notifier(myNotifier).error_handler = call CustomErrorHandler(?, ?, ?, ?, ?, ?, ?)

Run the file using the mlsrv11 -notifier option. For more information on how to configure a Notifier configuration file, see Configuring server-side settings using the Notifier configuration file.