---
schema_version: "1"
id: bd53283ad9999611f77a74b615a3d69f2051b8a35c112808174498896feabde9
title: "Handlebars Helper Function: raiseError"
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/handlebars/reference/utility/mcn-handlebars-reference-utility-raiseerror.md
canonical_url: https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-utility-references/mcn-handlebars-reference-utility-raiseerror.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7ffe54b597a6646997e18f316204c149dda46f80f26451f5978c2a73751e192c
products:
  - Handlebars for Marketing Cloud Next
  - Marketing Cloud
---
# 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

```handlebars
{{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.

```handlebars
{{#if (not isValid)}}
  {{raiseError "Validation failed"}}
{{else}}
  <!-- Content for valid scenario -->
{{/if}}
```

## See Also

- [fallback](https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-utility-references/mcn-handlebars-reference-utility-fallback.md)
- [if](https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/comparison/mcn-handlebars-reference-comparison-if.md)
- [unless](https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/comparison/mcn-handlebars-reference-comparison-unless.md)
