Core
IoT Platform v2.x
2

Errors tracking #

The Kuzzle IoT platform has an internal error tracking system.

Thus, the errors are systematically saved with their context in a collection in order to allow a future investigation or statistics.

Automatic error saving #

Errors are automatically saved except for those with the following statuses: 404, 401, 403 and 412.

All other errors are saved automatically with the following information:

  • error: error object containing
    • id: unique identifier of the error
    • name: error name
    • status: HTTP status code
    • message: error message
    • stack: complete stacktrace
  • context: object containing the context of the request, with in particular:
    • user: authenticated user
      • _id: user ID
      • profileIds: identifying profiles
  • input: object containing the input data, including:
    • controller: controller name
    • action: action name

It is then possible to consult this error list from the Admin Console.

Saving an error from the framework #

During a backend processing, it is possible to wish to save an error in the dedicated collection.

To do this, it is possible to use the iot-platform:error:save event with the error object and an arbitrary context as a parameter.

Example:

try {
  // some action that may fail
} catch (error) {
  this.app.trigger<EventIoTPlatformErrorSave>('iot-platform:error:save', {
    error,
    context: {
      foo: 'bar',
    },
  });
}