-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Description
When using lambda-api
together with some code bundler like rollup
class names are rewritten to avoid duplicates.
The class RouteError
will for example be rewritten to something like this:
class RouteError$1 extends Error {
constructor(message, path) {
super(message);
this.name = this.constructor.name;
this.path = path;
}
}
The use of this.name = this.constructor.name
will make it so that error.name
will be "RouteError$1"
and not "RouteError"
The result of this is that you can't use the error.name
property to check for the error type like mentioned in the docs
Instead you'll have to do some workaround like this:
if (err.name.includes('RouteError')) {
// do something with route error
}
Proposed solution
Simply set the error name to a static string to ensure that it's always the same, like this:
this.name = 'RouteError'
Metadata
Metadata
Assignees
Labels
No labels