Stops the processing of an email job and produces an error message. In journeys, this function removes a subscriber from only one send. It doesn’t remove them from other sends in the journey.

Email sends that result in this type of error aren’t counted as email usage in your billing utilization.

Marketing Cloud Engagement builds and pre-processes emails before it attempts to send them. Emails that weren’t sent because this function was called are included in your tracking and reporting metrics.

We recommend that you use this function only to handle errors, not as a method of segmenting subscribers. Use query activities and exclusion lists to handle segmentation requirements.

The RaiseError() function has five parameters:

  • errorMessage (string): Required. The error message to display when the error is raised.
  • boolSkipCurrentOnly (boolean): If true, the function skips only the subscriber for which the error was raised, and proceeds with the rest of the email job. If false, the function stops the entire email job when an error is raised. The default value is false.
  • apiErrorCode (string): A user-defined API error code.
  • apiErrorNumber (number): A user-defined API error number.
  • boolPreserveDataExt (boolean): If true, the function retains information written to data extensions before the error occurs, even if the subscriber is skipped. If false, the function doesn’t retain data extension information recorded before the error. This parameter applies to information that is inserted, updated, upserted, or deleted using AMPscript functions.

To use this function, pass it the string of text that you want to output when an error is found.

Typically, you place the function at a point in your code where a condition is tested, such as an if-else block. In this example, the code searches for a value in a data extension. If the code finds a matching row, it sets a variable to equal a field from the data extension. Otherwise, it raises an error and skips processing for the current subscriber.