On this page:

30.4Exceptions

 

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

See OAuth2 Exceptions for exceptions thrown by an OAuth2 callback.

30.4.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');

30.4.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');