Nuxeo Server

Error Handling

Updated: September 22, 2017 Page Information Edit on GitHub

The Nuxeo API communicates error messages through standard HTTP status codes paired with exception details.

You can find more details about standard HTTP status codes on:

Two modes are available:

  • Simple (without exception stack trace)

  • Extended (with exception stack trace)

Simple mode is activated by default. The extended mode can be configured through a parameter (in nuxeo.conf): org.nuxeo.rest.stack.enable=true.

Properties

Key Type Value
entity-type string 'exception' (in the case of exceptions)
code string The technical exception identity (Java class)
status integer The HTTP status of the error response
message string A human-readable message about the error
stacktrace string The entire stack trace in one string
exception JSON object The entire stack trace wrapped into a JSON Object

Exception Example

Here is an example of an exception when fetching a missing document.

Simple Mode

JSON Response

{
  "entity-type": "exception",
  "code": "org.nuxeo.ecm.webengine.model.exceptions.WebResourceNotFoundException",
  "status": 404,
  "message": "Failed to get document /wrongID"
}

Extended Mode

{
  "entity-type": "exception",
  "code": "org.nuxeo.ecm.webengine.model.exceptions.WebResourceNotFoundException",
  "status": 404,
  "message": "Failed to get document /wrongID",
  "stacktrace": "org.nuxeo.ecm.webengine.WebException: Failed to get document /wrongID\n\tat org.nuxeo.ecm.webengine.WebException.newException(WebException.java[.........]",
  "exception": {
    "className": "org.nuxeo.ecm.webengine.model.exceptions.WebResourceNotFoundException",
    "cause": {
      "className": "org.nuxeo.ecm.core.model.NoSuchDocumentException",
      "cause": null,
      "message": "No such document: No such document: /wrongID",
      "localizedMessage": "No such document: No such document: /wrongID",
      "stackTrace": [
      [.................................]
      ]
    }
  }
}

The Automation Client requires the full stack trace by default. So compatibility has been kept and all automation client calls will activate the extended mode.

All calls with accepted media type application/json+nxentity will activate stack trace display.

Mode Activation API

For testing purposes, you can activate the extended mode by adding this code snippet:

JsonFactoryManager jsonFactoryManager = Framework.getLocalService(JsonFactoryManager.class);
if (!jsonFactoryManager.isStackDisplay()) {
    jsonFactoryManager.toggleStackDisplay();
}

To toggle the display mode (simple or extended) during runtime execution, you can:

  • Use the Automation JsonStack.ToggleDisplay Operation (Administrator role only) Example:

    cURL Call

    curl -H 'Content-Type:application/json+nxrequest' -X POST -d '{"params":{},"context":{}}' -u Administrator:Administrator http://NUXEO_SERVER:8080/nuxeo/api/v1/automation/JsonStack.ToggleDisplay
    

  • Use the following endpoint URL in your browser (Administrator role only)

    Type into your browser address

    http://NUXEO_SERVER/nuxeo/site/automation/doc/toggleStackDisplay
    

2 days ago Solen Guitter Don't show excerpt 'upgrade-9.2-drop-change-token' and add comment
2 years ago Solen Guitter 14
2 years ago Solen Guitter 13 | format
3 years ago Solen Guitter 12 | Formatting and spelling
3 years ago Vladimir Pasquier 11
3 years ago Vladimir Pasquier 10
3 years ago Vladimir Pasquier 9
3 years ago Vladimir Pasquier 8
3 years ago Vladimir Pasquier 7
3 years ago Vladimir Pasquier 6
3 years ago Vladimir Pasquier 4
3 years ago Vladimir Pasquier 5
3 years ago Vladimir Pasquier 3
3 years ago Vladimir Pasquier 2 | adding web exception documentation
3 years ago Vladimir Pasquier 1
History: Created by Vladimir Pasquier