express-mongoose-es6-rest-api
express-mongoose-es6-rest-api copied to clipboard
(err instanceof APIError) always returning false
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
Which version of the boilerplate are you using?
version 1.0.0
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.
I'll take a look at it ! thank you @kitce