User-Defined Exception Messages

A user-defined exception message has the following format:

Exception: {ExceptionType}
{ExceptionJson}
  • Exception: (incl. colon) is a fixed token to indicate that this is a user-defined exception message.

  • ExceptionType specifies the type of the exception and the format of the following Json.

  • ExceptionJson contains the structured exception.

🔥 Please notice the single quotes are mandatory, especially when replacement variables are used.

'Exception: BadRequestException
{
  "statusCode" : "400",
  "userMessage"  : "Request parameters invalid",
  "rootCause" : "'{1}'"
}'

1: Dynamic Document Property - DDP_BusinessRuleResult

ExceptionBase

All exception messages should inherit from this base-class, containing a rootCauseand userMessagefield: (see ExceptionBase)

Exception: 
{
  "userMessage" : "Something went wrong! Please contact your admin!",
  "rootCause"   : "...technical message ..."
}

Examples

The data validation Business Rule failed and there is no way to continue code execution: throw a controlled Exception.

'Exception: ValidationFailedException
{
    "requestItemId" : "'{1}'",
    "userMessage"   : "'{2}'",
    "rootCause"     : "Business Rule Failure"
}'

1: Dynamic Document Property - DDP_RequestItemId
2: Dynamic Document Property - DDP_BusinessRuleResult

Last updated