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

(err instanceof APIError) always returning false #447

Open
skoope opened this issue Mar 27, 2018 · 4 comments
Open

(err instanceof APIError) always returning false #447

skoope opened this issue Mar 27, 2018 · 4 comments

Comments

@skoope
Copy link

skoope commented Mar 27, 2018

in config/express.js :

else if (!(err instanceof APIError)) {
    const apiError = new APIError(err.message, err.status, err.isPublic);
    return next(apiError);
  }

is supposed to catch errors that aren't instanceof APIError and convert them, but this always return false :
example :

const err = new APIError('Not found', 404, true);
console.log(err instanceof APIError) // false
console.log(err instanceof Error) // true
@kitce
Copy link

kitce commented Mar 29, 2018

Which version of the boilerplate are you using?

@skoope
Copy link
Author

skoope commented Mar 30, 2018

version 1.0.0

@kitce
Copy link

kitce commented Mar 30, 2018

I guess that's because of Babel.

You may need to use babel-plugin-transform-builtin-extend to make instanceof works as expected in Babel environment.

Take a look of this.

@skoope
Copy link
Author

skoope commented Mar 30, 2018

I'll take a look at it ! thank you @kitce

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