You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// instanceof is a liar. Use error.type or invent your own API and stick to it.throwFaunaError(Error("JavaScript !== Python && JavaScript !== Java && JavaScript !== ..."));
Benefits of this approach:
Preserves the stack trace and all other desirable properties of an error.
No need to use the new keyword.
Simplifies your codebase and gets rid of all sub-typing boilerplate code e.g. _utils/inherits.
There might be downsides to this approach but I doubt any would be worse than loosing the stack trace.
Regardless of whether you like this approach or not FaunaError eats the stack trace and that's a bug.
The text was updated successfully, but these errors were encountered:
faunadb-js/src/errors.js
Lines 21 to 41 in 18d58e7
Extending the Error object is not ideal in JavaScript. You're better-off just decorating instances of Error like this:
And then when you need to use it:
Benefits of this approach:
new
keyword._utils/inherits
.There might be downsides to this approach but I doubt any would be worse than loosing the stack trace.
Regardless of whether you like this approach or not FaunaError eats the stack trace and that's a bug.
The text was updated successfully, but these errors were encountered: