Catch Exceptions
In the Catch block we encounter two different scenarios:
a controlled exception has been caught or
an uncontrolled exception has been caught.
We want to treat both situations equally in the catch block.
Set
DDP_TryCatchMessage
= Document Property - Base - Try/Catch MessageUse the created Dynamic Document Properties to handle the Exception.

Exception Base Class
The ParseExceptionMessage Script
Source Code on GitHub
The script parses an exception message (expected in [DDP_TryCatchMessage])
and sets well-defined document properties. If [DDP_TryCatchMessage] does not contain a
structured error Json, [DDP_TryCatchMessage] is routed to [DDP_rootCause] property.
If [DDP_TryCatchMessage] is not set the script throws an exception.
The [DDP_TryCatchMessage] must start with "Exception:" (case-sensitive) so that the script runs.
The script parses the following text into dynamic document properties as follows:
Exception: {DDP_ExceptionType}
{DDP_ExceptionJson}
The [DDP_ExceptionJson] is then interpreted as JSON and all elements on the first level
will be turned into dynamic document properties, too. All nested elements are skipped when creating DDPs.
For example:
DDP_TryCatchMessage=
Exception: ApplicationException
{
"statusCode" : 404,
"rootCause" : "Record not found!"
}
DDP_exceptionType='ApplicationException'
DDP_exceptionJson='{
"statusCode": 404,
"rootCause": "Record not found!"
}'
DDP_statusCode ='404'
DDP_userMessage='Something went wrong! Please contact your admin!'
DDP_rootCause = 'Record not found!'
Last updated