Created on 14 November 2021
icon_unfollowing
Login to follow
gexceptions

GExceptions

Stable version 1.0.1 (Compatible with OutSystems 11)
Uploaded on 14 November 2021 by 
gexceptions

GExceptions

Documentation
1.0.1

GExceptions

This is a proposed solution to be able to create exceptions that can be used and shared among Outsystems modules. Any feedback or suggestions are more than welcome.

Define your custom user Exceptions

While using this module to handle custom user exceptions and be able to share them between modules the first needed step is to configure your user exceptions, which should be made by adding the exceptions to the entity UserException inside the GExceptions_Lib Module.


All user exceptions that are meant to be shared among modules should be created on this entity.  

Throw Exceptions

Add the module GExceptions_Lib to your module, and add the ThrowException action. 

Then in your logic you can throw the new custom exceptions like this :

The throw exception receives two parameters :

  • UserExceptionId -> this will be any of the types defined on the first step
  • ExceptionMessage -> Any custom message you want to add to the exception.


Handle Exceptions

Add the module GExceptions_Lib to your module, and add the CatchException action. 

Then in the logic for the action add the following code: 


CatchException receives one parameter which is the following:

  • ExceptionMessage ->  must be the the exception message received on ExceptionHandler node.

And returns one object of type exception with the following attributes:

  • UserExceptionId -> this will be any of the types defined on the first step
  • ExceptionMessage -> Any custom message you want to add to the exception.


This way it is possible to handle the exceptions depending on the Id of the exception received.


NOTE: Both ThrowException and CatchException from the GException_Lib module have a client and a server version in order to be possible to use them in client code or server code, but they both share the same entities so if an exception is thrown by the server and is not catch before , then it is possible to catch that exception on the client, as long as it was the client callling the server action that led to that exception.




Support options
This asset is not supported by OutSystems. You may use the discussion forums to leave suggestions or obtain best-effort support from the community, including from  who created this asset.
Dependencies
GExceptions has no dependencies.