Use the THROW statement to generate a user exception.
>>-THROW--+------+--EXCEPTION--+----------------------+---------> '-USER-' '-SEVERITY--expression-' >--+-----------------------+--+-------------------------+-------> '-CATALOG--catalog name-' '-MESSAGE--message number-' >--+------------------------------+---------------------------->< | .-,----------. | | V | | '-VALUES--(----expression-+--)-'
SEVERITY is an optional clause that determines the severity associated with the exception. The clause can contain any expression that returns a non-NULL, integer value. If you omit the clause, it defaults to 1.
On Windows you must set SEVERITY to 3, so that the Windows event log reports the error correctly.
CATALOG is an optional clause; if you omit it, CATALOG defaults to the IBM® Integration Bus current version catalog. To use the current version message catalog explicitly, use BIPmsgs on all operating systems.
MESSAGE is an optional clause; if you omit it, it defaults to the first message number of the block of messages provided for using THROW statements in the default catalog (2951). If you enter a message number in the THROW statement, you can use message numbers 2951 to 2999 from the default catalog. Alternatively, you can generate your own catalog by following the instructions in Creating message catalogs.
Use the optional VALUES field to insert data into your message. You can insert any number of pieces of information, but the messages supplied (2951 - 2999) cater for eight inserts only.
THROW USER EXCEPTION;
THROW USER EXCEPTION CATALOG 'BIPmsgs' MESSAGE
2951 VALUES(1,2,3,4,5,6,7,8) ;
THROW USER EXCEPTION CATALOG 'BIPmsgs' MESSAGE
2951 VALUES('The SQL State: ',
SQLSTATE, 'The SQL Code: ', SQLCODE, 'The SQLNATIVEERROR: ', SQLNATIVEERROR,
'The SQL Error Text: ', SQLERRORTEXT ) ;
THROW USER EXCEPTION CATALOG 'BIPmsgs' MESSAGE
2951 ;
THROW USER EXCEPTION CATALOG 'MyCatalog' MESSAGE
2951 VALUES('Hello World') ;
THROW USER EXCEPTION MESSAGE
2951 VALUES('Insert text 1', 'Insert text 2') ;
For more information about how to throw an exception, and details of SQLSTATE, SQLCODE, SQLNATIVEERROR, and SQLERRORTEXT, see ESQL database state functions.