Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot compare error using instanceof #81

Closed
seoker opened this issue Sep 13, 2017 · 2 comments
Closed

cannot compare error using instanceof #81

seoker opened this issue Sep 13, 2017 · 2 comments

Comments

@seoker
Copy link

seoker commented Sep 13, 2017

Based on README, the error should be compared using instanceof operator.

for example

const errors = require('restify-errors');
const err = new errors.ResourceNotFoundError();
err instanceof errors.ResourceNotFoundError; // true

However I couldn't compare them in a specific case under restify:

// trigger this error when some in-existing route being called
server.on('NotFound', (req, res, err, cb) => {
  req.log.info(JSON.stringify(err, null, 2)); // { "code": "ResourceNotFound", "message": "/xxxx does not exist" }
  req.log.info(err.toString()); // ResourceNotFoundError: /xxxx does not exist
  req.log.info(err.code); // Error
  if (err instanceof errors.ResourceNotFoundError) {
    // never get here
  }

  cb();
});

kind of weird, any ideas?
I'm not sure where is better to report this issue, restify or this repo?

versions
restify: 5.2.0
restify-errors: 5.0.0

@seoker
Copy link
Author

seoker commented Sep 15, 2017

Had opened an issue at restify/restify#1496

@DonutEspresso
Copy link
Member

Thanks for bringing this our attention! Let's keep the convo going at restify/node-restify#1496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants