Handlebar Helper Function: RaiseError

Throws an exception with a specified error message and optional error code. Use this helper to interrupt template rendering when you need to enforce validation rules or signal error states. When this helper executes, it prevents the template from completing. Consuming services can access the error details.

Availability 

This helper is available in the Summer ’26 release of Marketing Cloud Next (API version 67.0).

Syntax 

1{{raiseerror errorMessage errorCode}}

Parameters 

ParameterTypeDescription
errorMessageStringRequired. The error message to include in the exception.
errorCodeStringAn error code for categorizing or programmatically identifying errors.

Return Value 

This helper always throws a RaiseErrorHelperException that contains the provided message and optional error code.

The exception that this helper throws can’t be caught or handled by the fallback helper.

Usage 

Use this helper alone or with conditional logic. This example shows the function within an if-else block.

1{{#if (not isValid)}}
2  {{raiseerror "Validation failed"}}
3{{else}}
4  <!-- Content for valid scenario -->
5{{/if}}

See Also