top | item 37954316

(no title)

gatestone | 2 years ago

Designing better error handling in Go is an ongoing work. Proposols are being considered. Personally I don't see a big problem in real life Go code bases.

Note that there is kind of a philosophical cul-de-sac here. If you understand and expect your "errors" (= exceptional situations that prevent the program to do what we thought the user wanted) you can handle them, and they become part of your program normal logic.

If you don't understand or ainticipate your errors, or choose to neglect situations that are not really rare or are really dangerous, no amount of special language constructs will save your users.

https://go.googlesource.com/proposal/+/master/design/go2draf...

discuss

order

Cthulhu_|2 years ago

> = exceptional situations that prevent the program to do what we thought the user wanted

Just to latch onto this remark, are they actually exceptional? Say you have a REST API, does something with a database. 1 in 1000 requests fails, so it's exceptional I suppose. But then you go web scale, and your application gets called a million times per minute. Suddenly you're dealing with 1000 errors per minute; not so exceptional anymore.

Besides, errors can also be things like 'SQL row not found', which are expected in the normal run of things.