Firebird Documentation Index → Firebird 2.1 Language Ref. Update → PSQL statements → EXCEPTION |
Table of Contents
Find a more recent version at Firebird 5.0 Language Reference: EXCEPTION
Available in: PSQL
Changed in: 1.5
Description: The EXCEPTION syntax has been extended so that the user can
Rethrow a caught exception or error.
Provide a custom message when throwing a user-defined exception.
Syntax:
EXCEPTION [<exception-name>
[custom-message
]]<exception-name>
::= A previously defined exception name
Within the exception handling block only, you can rethrow the caught exception or error by giving the EXCEPTION command without any arguments. Outside such blocks, this “bare” command has no effect.
Example:
when any do begin insert into error_log (...) values (sqlcode, ...); exception; endThis example first logs some information about the exception or error, and then rethrows it.
Firebird 1.5 and up allow you to override an exception's default error message by supplying an alternative one when throwing the exception.
Examples:
exception ex_data_error 'You just lost some valuable data';exception ex_bad_type 'Wrong type for record with id ' || new.id;
Starting at version 2.0, the maximum message length is 1021 instead of 78 characters.
Firebird Documentation Index → Firebird 2.1 Language Ref. Update → PSQL statements → EXCEPTION |