Y
Hacker News
new
|
ask
|
show
|
jobs
by
serguzest
314 days ago
One thing you should add to section 10 is encouraging people to pass `cause` option while throwing new Error instances. For example
new Error("something bad happened", {cause:innerException})
2 comments
seniorsassycat
314 days ago
It's wild that that's not what the section is about. Extending error is not new at-all.
link
serguzest
314 days ago
Most people (including the author apparently) don't know they can chain errors with cause option in-built way in node and in browser. It is not just arbitrary extending and it is relatively a new thing.
https://nodejs.org/api/errors.html#errorcause
link
seniorsassycat
307 days ago
I've found that a lot of logging frameworks and patterns will not include cause which can absolutely fuck debugging
link
upcoming-sesame
314 days ago
Cool didn't know about this
link