Thank you for your feedback.
Form temporarily unavailable. Please try again or contact docfeedback@servicenow.com to submit your comments.
Versions
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store
Close

GenericException

GenericException

This JavaScript method provides generic exception wrapping.

Where to use

Use these methods to define exception handling in your JavaScript code.

Method summary

Method summary Description
initialize(errorMessage) Method called by the Prototype JavaScript Framework during object creation.
getMessage() Gets the error message.
toString() Converts the error message to a string.

Method detail

initialize(errorMessage)
Called by the Prototype JavaScript Framework during object creation to initialize a new instance of this class. Provide the parameter value but do not directly call this method.
  • Input field parameters: errorMessage: (string) the error message.
  • Output field returns: void.

Example that returns void:

var jerr = new  GenericException("This is an error");
getMessage()
Gets the error message.
  • Input field parameter: none
  • Output field returns: (string) the error message.

Example:

var jerr = new  GenericException("This is an error");
gs.print(jerr.getMessage());

Returns the output: *** Script: This is an error

toString()
Converts the error message to a string.
  • Input field parameter: none
  • Output field returns: (string) the error message.

Example:

var jerr = new  GenericException("This is an error");
gs.print(jerr.toString());

Returns the output: *** Script: This is an error

This site is scheduled for a small content update on Tuesday, December 18th, between the hours of 4:00pm and 8:00pm Pacific Time (Dec 19 00:00 – Dec 19 4:00 UTC). Access to this site may be slightly delayed during that time.