EXCEPTION HANDLER action


Function Action defines a start of actions which handle an error (so called exception handler) and defines an area of their operation.
Declaration
EXCEPTION_HANDLER
Description EXCEPTION_HANDLER action defines the start of actions which handle the error (so called exception handler) and defines the area of their operation.
According to context where the action is used, it can cause:
  • End of script execution - if the action is used out of 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 in 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. 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 their 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

Napíšte komentár