WLJS LogoWLJS Notebook

CatchExceptions

CatchExceptions[expr, spec]
CatchExceptions[spec][expr]

catches and transforms exceptions thrown while evaluating expr. The specification can select all exceptions, a type and its subtypes, or multiple type-to-handler rules.

Examples

Use the default handler for every exception:

CatchExceptions[
  ThrowException["Error", 42],
  All
]

Provide a handler:

CatchExceptions[
  ThrowException["Error", 42],
  "Error" -> Function[data, data["ExceptionPayload"]]
]

See the official Wolfram Language reference for handler data and matching rules.

On this page