Scripted REST API error objects

Scripted REST APIs include error objects that allow you to respond to a request with a standard HTTP error message when an error occurs during request processing.

You can use error objects in scripted REST API resources to alert requesting clients of errors. Use error objects to respond to incoming requests, not to catch errors within your server-side code.

Error response format

The content type of the response depends on the request Accept header. If the Accept header specifies an unsupported format, such as image/jpeg, the error response uses JSON.

Error responses follow this format:
{
  "error": {
    "message": "My error message",
    "detail": "My details"  
  },  
  "status": "failure"
}
The numeric status code, such as 404, is included in the response Status code header, not in the response body.