sjmeverett / promised-ldap

A thin wrapper over ldapjs to give a promise interface and authentication helpers.
23 stars 11 forks source link

Dealing with 'connect ECONNREFUSED' issues #7

Open ghost opened 7 years ago

ghost commented 7 years ago

When the server details you are connecting to are not correct, say, hostname or port etc are not valid, it manifests as a 'connect ECONNREFUSED' error and terminates the running process. For now, I am using process.on('uncaughtException', function (err) {} to catch this. With just the ldapjs library, seems like you can use the error event to catch this but how to best deal with this using the promised-ldap library?

zerr0s commented 6 years ago

+1 same problem. I've added follwing code to index.js of the library to handle error on connection:

this.client.on('error', (e) => {
  throw e;
});

and use try/catch on the main code. Is there a better way ?