ldapjs-promise Errors API

This document covers the ldapjs-promise errors API and assumes that you are familiar with LDAP. If you are not, read the guide first.

All errors in the ldapjs-promise framework extend from an abstract error type called LDAPError. In addition to the properties listed below, all errors will have a stack property correctly set.

In general, you will be using the errors in ldapjs-promise like:

import {
  NoSuchObjectError,
  EntryAlreadyExistsError
} from 'ldapjs-promise';

const db = {};

server.add('o=example', (req, res, next) => {
  const parent = req.dn.parent();
  if (parent) {
    if (!db[parent.toString()])
      return next(new NoSuchObjectError(parent.toString()));
  }
  if (db[req.dn.toString()])
    return next(new EntryAlreadyExistsError(req.dn.toString()));

  ...
});

I.e., if you just pass them into the next() handler, ldapjs-promise will automatically return the appropriate LDAP error message, and stop the handler chain.

All errors will have the following properties:

code

Returns the LDAP status code associated with this error.

name

The name of this error.

message

The message that will be returned to the client.

Complete list of LDAPError subclasses