On this page:

20.3Exceptions

 

The Exceptions API can be used to create exceptions within JavaScript code.

20.3.1Method: Exceptions.newTrustedException(theMessage)

 

Creates an exception that is marked as trusted, meaning that the message will be returned to the client even if Suppress Error Details is enabled.

Inputs:

  • theMessage – The error message

Outputs:

  • Returns an exception that can be thrown

Example:

throw Exceptions.newTrustedException('Database is unavailable');

20.3.2Method: Exceptions.newTrustedException(theStatusCode, theMessage)

 

Creates an exception that is marked as trusted, meaning that the message will be returned to the client even if Suppress Error Details is enabled.

Inputs:

  • theStatusCode – The HTTP status code that should be returned to the client
  • theMessage – The error message

Outputs:

  • Returns an exception that can be thrown

Example:

throw Exceptions.newTrustedException(500, 'Database is unavailable');