Exception_Handler Rule

Official Content
This documentation is valid for:
It provides a way to perform actions when a not managed exception occurs at runtime. 

Syntax

Exception_Handler(‘subname');

Where:
subname
Is the name of a subroutine contained in the program which makes use of this rule.

Description

The exception_handler rule is declarative. 

Defining this rule (and its associated subroutine) does not affect its flow, output or exit code. It just allows using the moment after an exception happens, for some useful action like notification of someone, so that monitors can take action on the happened exception. 
The performed action should be a safe one, not one that could also fail.
 

It is possible to get more detailed information about the exception, defining the following variables and using them in the subroutine.

Name Description
&GXexceptionType Name of the platform-specific type of exception
&GXexceptionDetails Message, reason, or detailed information associated with the exception
&GXexceptionStack  Runtime stack trace information about the exception location

Considerations

  • If an object A calls object B, both have an Exception_Handler defined, and an exception occurs in B, then the subroutines of both objects are executed
  • If an object A calls object B, A has an Exception_Handler defined, and an exception occurs in B, then the subroutines of A is executed

Example

Rules:

Exception_Handler('ExceptionNotifier');

Source:

.....

Sub 'ExceptionNotifier'
    NotifyException(&GXExceptionType, &GXExceptionDetails, &GXExceptionStack) //sends a notification of some kind to sysadmin
EndSub

Scope

Objects: Procedures, Transactions, Web Panels
Languages: .Net, Java,

Availability

Exception_Handler Rule is available since GeneXus 16 upgrade 7.

See Also