SDK
SDK Javascript v5.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

Error Handling #

Copied to clipboard!
// Any API request method behave the same way
// Using callbacks (NodeJS or Web Browser)
kuzzle.checkToken(token, function (err, res) {
  if (err) {
    console.error(err.status, ': ', err.message);
    return;
  }
});
// Using promises (NodeJS only)
kuzzle.checkTokenPromise(token)
  .then(res => {
    // ...
  })
  .catch(err => {
    console.error(err.status, ': ', err.message);
    return Promise.reject(err);
  });

All methods that accept a callback as an argument can return an error. The error can be generated directly by the SDK, or by Kuzzle and included in the response to a request.

All errors generated by Kuzzle contain the following properties:

  • message: the error message
  • status: an error code following the HTTP standard