Add ConnectionError and RequestError to module.exports #489

Merged
merged 1 commit into from Jan 12, 2017

Projects

None yet

3 participants

@jeffrosenberg

Unless I'm missing something, it seems that you can't easily instantiate a ConnectionError or RequestError with the current exports from tedious.js. I find that this makes it difficult to interrogate errors returned from the library, i.e. by using instanceof, such as in the following code:

tds.process(function(err, data) {
  if (err) {
    if (err instanceof ConnectionError) {
      manageConnectionError(err);
    } else if (err instanceof RequestError) {
      manageRequestError(err);
    }
  }
  else {
    doStuff(data);
  } 
});

It seems like exporting the error types would make it easier to write code like the above.

I'm relatively new to working with JavaScript, so it may be that there's a reason this isn't being done, or that this isn't actually necessary. My apologies if that's the case.

Jeff Rosenberg Add ConnectionError and RequestError to module.exports
81cea94
@tvrprasad

Looks reasonable to me.

I'll give it a little time before I merge, to see if @arthurschreiber has other insights, which he usually does :-)

@arthurschreiber

This is looking great, thanks! ❤️

@tvrprasad Feel free to merge anytime!

@tvrprasad tvrprasad merged commit d30e491 into tediousjs:master Jan 12, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@tvrprasad
Collaborator

Thanks for the contribution :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment