promised-ldap icon indicating copy to clipboard operation
promised-ldap copied to clipboard

Dealing with 'connect ECONNREFUSED' issues

Open ghost opened this issue 8 years ago • 1 comments

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?

ghost avatar Jan 11 '17 06:01 ghost

+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 ?

zerr0s avatar Feb 13 '18 12:02 zerr0s