EXCEPTION HANDLER action


FunctionAction defines a start of actions that handle an error (so-called exception handler) and defines an area of their operation.
Declaration
EXCEPTION_HANDLER
DescriptionEXCEPTION_HANDLER action defines the start of actions that handle the error (so called exception handler) and defines the area of their operation.
According to the context where the action is used, it can cause:
  • End of script execution - if the action is used out of the procedure.
  • End of procedure execution - if the action is used within the procedure.
If EXCEPTION_HANDLER action is in some procedure the exception handling ends on this action and starts either by previous EXCEPTION_HANDLER action or by the procedure.
If EXCEPTION_HANDLER action is out of procedure it defines the exception handler for errors occurring in the actions of an initialization part of script and initialization of the global variables.

EXCEPTION_HANDLER action must not define the error handler for ON ERROR action.

For example:


 PROCEDURE Proc2
  ; incorrect placement of the command
  ON ERROR Error
 
  INT _i
  CALL Proc1
  Error:
 
 EXCEPTION_HANDLER
  ; exception handling from the start of procedure to EXCEPTION_HANDLER action
 END Proc2

When EXCEPTION_HANDLER action is executed, it is interpreted as RETURN action. The following two procedures are the same:

PROCEDURE Proc1
  ; actions
  ; .....
 
  RETURN
 EXCEPTION_HANDLER
  ; exception handling
 END Proc1 

or

 PROCEDURE Proc1
  ; actions
  ; .....
 
 EXCEPTION_HANDLER
  ; exception handling
 END Proc1 

EXCEPTION_HANDLER action may handle the exceptions which occur while there are serviced:

PROCEDURE Proc3
  ; actions
  ; ....
 
 EXCEPTION_HANDLER
  ; exception handling from start of procedure to EXCEPTION_HANDLER action
 
 EXCEPTION_HANDLER
  ; exception handling from the previous EXCEPTION_HANDLER action
 
 END Proc3

0 komentárov

Nie ste prihlásený. Akékoľvek zmeny, ktoré vykonáte, sa označia ako anonymné. Ak už máte svoj účet, pravdepodobne sa budete chcieť prihlásiť .