INFORMIX
DataBlade API Programmer's Manual
Chapter 9: Event and Exception Handling
Home Contents Index Master Index New Book

Errors

On failure, DataBlade API functions return MI_ERROR if the return value is an integer and NULL if the return value is a pointer. If an error is raised and callback functions are called, control is returned to the caller of the DataBlade API function only if the error is handled.

Most library errors are caused by invalid arguments. The following list describes the most common errors:

Potential exceptions other than these types of common invalid arguments are mentioned in the Return Values section of the individual function descriptions where appropriate.

Client Errors

The DataBlade API raises a client library error, MI_Client_Library_Error, when it encounters an error in a client application. A client library error is one of the following types:

When an MI_Client_Library_Error event occurs, a call to the DataBlade API function mi_error_level() returns the type of library error.

Exception Raising

A user function can raise an exception by calling mi_db_error_raise(). In a client application, the mi_db_error_raise() function sends the exception to the database server. In the database server, it raises an exception. This function can then display a literal message string by passing the following information to the default callback:

Exceptions can also be raised by referencing a SQLSTATE value stored in the syserrors system catalog table. This table maps error and warning messages to five-character SQLSTATE values. The mi_db_error_raise() function can be called from a server function to display the stored message string associated with a particular SQLSTATE value in the syserrors system catalog table. If the stored message contains parameter markers, mi_db_error_raise() can handle a variable-length parameter list.

A standard SQLSTATE value consists of five characters. Legal characters are 0 to 1 and A to Z. A code is divided into a two-character class code followed by a three-character subclass code. The class code denotes a general class of condition and the subclass code a more narrowly defined condition within the class code classification.

User-created status codes and their associated messages are stored in the syserrors system catalog table. Users can add their own status codes and messages to this table. However, SQL reserves various codes for its use.

To create a new message, insert a row directly into the syserrors system catalog table. By default, all users can view this table, but only users with the DBA privilege can modify it.

GLS
Enter message text in the language of the target locale, using any characters available in the code set, though by convention, the message does not include any newline character.

Sequences of characters enclosed by a single percent sign on each end (for example, %TOKEN%) are treated as variables when supplied with matching values. When preparing the message for output, the database server replaces each variable with its actual value.

The database server searches for the message in which all components of the locale (language, territory, and code set) match its own. If only the language and territory match, it converts the code set. If there is no message with matching language and territory, it uses the first available message with the correct language. If there is no message in the appropriate language, it uses the message for the default language, en_us.

Messages are converted to the appropriate code set and formatting styles before being sent to the client.

For more information on the syserrors system catalog table, see the Informix Guide to SQL: Syntax.

For more information about mi_db_error_raise(), see the description of this function in Chapter 12.




DataBlade API Programmer's Manual, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.