Common resources - How to Force the Request to Fail

When leveraging JavaScript in a Common Resource, you force the request to fail by throwing an error. The error message that is passed to Error will be returned in the response from Sugar Integrate

In the JavaScript:

throw new Error('Your error message with context regarding request');

In the case of an error, the response from Sugar Integrate:

{
  "requestId": "5db2f26ee4b02bd2e4dc6fa5",
  "message": "Javascript failed to execute: Your error message with context regarding request"
}