Verification in progress Test scripts included

Syntax

RaiseError(message[, skipSubscriber, apiErrorCode, apiErrorNumber, preserveDataExt])  →  void
1–5 arguments

Parameters

Name Type Required Description
message string Yes Error message
skipSubscriber string | boolean | number No Skip only the current subscriber and continue the job, rather than stopping it. Accepts true, false, 1, 0, "true", "false", "1", "0"
apiErrorCode string No Custom API error code
apiErrorNumber number No Custom API error number
preserveDataExt string | boolean | number No Retain earlier data-extension writes; allowed values: true, false, 1, 0, "true", "false", "1", "0"

Example

%%[
  IF 1 == 2 THEN
    RaiseError("probe")
  ENDIF
]%%
gated

Renders gated: the branch never runs, so the call does nothing. An email with a branch like this saves and publishes.

Return value

void — nothing is returned. When the call runs, the render fails instead.

Behaviour

A call that runs stops the render. An email with RaiseError("message") saves and publishes, but the preview fails with HTTP 500 and no message. Text before and after the call does not help: before%%[ RaiseError("…") ]%%after fails the same way.

The optional arguments do not change that. Calls with a second argument of true, 1 or "true", and five-argument calls ending in 1, "true" or true, each save and then fail the preview.

A sixth argument is not caught at save. RaiseError("…", 1, "R2", 100, 1, 1) saves, then fails the preview like the others.

An empty call is rejected at save. RaiseError() gives HTTP 400, “The AMPscript syntax isn’t valid”.

What happens during a real send (stopping the job, skipping a subscriber, error codes) was not tested in Next.

Show Next test script
<!-- Marketing Cloud Next test script for RaiseError. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[gated] got=[%%[IF 1 == 2 THEN RaiseError("probe") ENDIF]%%gated]</p>

Show calls that fail in Next (one email each)
<!-- Run each call below in its own Next email: one of them in a combined email
     would stop the whole preview or block the save. -->

<!-- email 1: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-raiseerror-msg") ]%%

<!-- email 2: expect that the email saves, but the preview fails (HTTP 500) -->
r2-before%%[ RaiseError("r2-raiseerror-order") ]%%r2-after

<!-- email 3: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-re-p2-true", true) ]%%

<!-- email 4: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-re-p2-n1", 1) ]%%

<!-- email 5: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-re-p2-qtrue", "true") ]%%

<!-- email 6: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-re-p5-n1", 1, "R2", 100, 1) ]%%

<!-- email 7: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-re-p5-qtrue", 1, "R2", 100, "true") ]%%

<!-- email 8: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-re-p5-btrue", 1, "R2", 100, true) ]%%

<!-- email 9: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ RaiseError("r2-re-invalid-arity", 1, "R2", 100, 1, 1) ]%%

<!-- email 10: expect that the save is rejected (HTTP 400) -->
%%[ RaiseError() ]%%

Availability & differences

PlatformAvailable
Marketing Cloud EngagementYes
Marketing Cloud NextYes, from API 67.0
Same in Marketing Cloud Engagement

Both platforms abort when the call runs and refuse an empty call. Engagement CloudPages answer HTTP 422 with a fixed notice; the Next email preview fails with HTTP 500. Compared 2026-11-23 by rendering the same calls in a Marketing Cloud Next email.

See also