Handlebars 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.

Syntax

{{raiseError errorMessage errorCode}}

Parameters

Parameter Type Description
errorMessage String Required. The error message to include in the exception.
errorCode String An 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.

{{#if (not isValid)}}
  {{raiseError "Validation failed"}}
{{else}}
  <!-- Content for valid scenario -->
{{/if}}

See Also