Official Content

Provides a way to perform actions when a non-managed exception occurs at runtime. 

Syntax

Exception_Handler(‘subname');

Where:

subname
    Is the name of a subroutine contained in the GeneXus object that uses this rule.


Scope

Objects: Procedure, Transaction, Web Panel
Generators: .NET.NET Framework, Java


Description

The exception_handler rule is declarative.

Defining this rule (and its associated subroutine) does not affect its flow, output, or exit code.
It will be executed after an exception is triggered. Then, it is intended to trigger an action such as sending a notification, so that those monitoring it can act on the exception. 
The action performed should be a safe one, not one that could also fail.

It is possible to get more detailed information about the exception by 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 when both have an Exception_Handler defined and an exception occurs in B, the subroutines of both objects are executed.
  • If an object A calls object B when object A has an Exception_Handler defined and an exception occurs in B, the subroutine of A is executed.


Samples

Consider the following Rule defined in a Procedure object:

Exception_Handler('ExceptionNotifier');

The following Subroutine is defined in the Procedure Source, to be executed when a non-managed exception occurs at runtime:

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

Availability

Exception_Handler Rule is available since GeneXus 16 upgrade 7.

See Also

 


Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant