README.exception_handling 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ------------------
  2. Exception handling
  3. ------------------
  4. The common syntax rules for EXCEPTION statement is:
  5. EXCEPTION [[name] [value]];
  6. Run-time exception messages (FB 1.5)
  7. ------------------------------------
  8. Function:
  9. Allows to throw exceptions with text message
  10. defined at runtime.
  11. Author:
  12. Dmitry Yemanov <[email protected]>
  13. Syntax rules:
  14. EXCEPTION <exception_name> <message_value>;
  15. Scope:
  16. PSQL
  17. Example(s):
  18. 1. EXCEPTION E_EXCEPTION_1 'Error!';
  19. 2. EXCEPTION E_EXCEPTION_2 'Wrong type for record with ID=' || new.ID;
  20. Exception re-raise semantics (FB 1.5)
  21. -------------------------------------
  22. Function:
  23. Allows to re-initiate catched exception.
  24. Author:
  25. Digitman <[email protected]>
  26. Syntax rules:
  27. EXCEPTION;
  28. Scope:
  29. PSQL, context of the exception handling block
  30. Example(s):
  31. BEGIN
  32. ...
  33. WHEN SQLCODE -802 THEN
  34. EXCEPTION E_ARITH_EXCEPT;
  35. WHEN SQLCODE -802 THEN
  36. EXCEPTION E_KEY_VIOLATION;
  37. WHEN ANY THEN
  38. EXCEPTION;
  39. END
  40. Note(s):
  41. Evaluates to no-op if used outside the exception handling block.
  42. Run-time error codes (FB 1.5)
  43. -----------------------------
  44. Function:
  45. Allows to get a numeric error code for the catched exception.
  46. Author:
  47. Dmitry Yemanov <[email protected]>
  48. Syntax rules:
  49. SQLCODE / GDSCODE;
  50. Scope:
  51. PSQL, context of the exception handling block
  52. See also:
  53. README.context_variables