40.6.1Exceptions

 

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

See OAuth2 Exceptions for exceptions thrown by an OAuth2 callback.

40.6.2Method: 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');

40.6.3Method: 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');