Open ghost opened 2 years ago
This seems to happen because TypeError.prototype instanceof Error
returns true (and in general, SubClass.prototype instanceof ParentClass
– this is not a bug, it's how JS works). This leads to the prototypes of native errors being treated as if they were errors in our console implementation:
And inspectError
prints the error's stack
property followed by any causes, but the prototypes of native errors don't have a stack
property, so it's undefined
that gets printed.
Here's how the different browsers log the native error prototypes:
For regular errors, Chrome prints the stack, but for native error prototypes it seems to log them as error objects. The other browser engines do something specific to the native error prototypes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
All of the built-in error classes, besides
Error
, haveprototype
objects that show as"undefined"
when logged, yet they're not actuallyundefined
!Example test code:
Yet, observe that they're objects:
Very misleading, and threw me off while messing with the error prototypes :sweat_smile: