Skip to content Skip to sidebar Skip to footer

Throwing Custom Error Doesn't Preserve Error Formatting In The Log

JavaScript, when throw-ing a built-in error as such: throw new Error('Something was wrong'); displays the text nicely - you can't tell you threw an object However, when creating

Solution 1:

As Pointy correctly pointed out (pun intended), the issue here is not with JavaScript, but rather with the environment JavaScript is running (in this case, Google Chrome).

In another environment (like Chromium, Firefox, NodeJS, etc.) the behavior will likely be different, using the same code, depending on how those JavaScript hosts are handling these cases.


Post a Comment for "Throwing Custom Error Doesn't Preserve Error Formatting In The Log"