logoalt Hacker News

gwdlast Tuesday at 7:26 PM1 replyview on HN

I mean, yeah, most of the time what you do is add more text and bubble up. But:

1. The very fact that adding more text isn't really any more verbose than not encourages you to add more text, making errors more informative.

2. A non-negligible amount of times you do something else: carry on, or do something specific based on what kind of error it was. For instance, ignore an error if it's in a certain class; or create the file if it didn't exist; and so on.

Forcing the error handling doesn't seem to me that different than forcing you to explicitly cast between (say) int and int64. Part of me is annoyed with that too, but then I have PTSD flashbacks from 20 years of C programming and appreciate it.


Replies

DangitBobbylast Wednesday at 3:11 PM

> making errors more informative.

It makes them almost as informative as languages with stack traces! Imagine if Go had a syntax like python's

    raise Exception("bad thing happened") from err
I'd love that.