Re:Lies we tell ourselves to keep using Golang
by sshine on Thursday November 28, 2024 @02:45AM
(#42263353)
> You're choosing to write the `?`
...but you're not choosing to write the `throws FooException`?
I can only say that if the `?` weren't around and you had to write more verbose handling each time, having the question "How should this one particular error be handled?" might come up more often and might prevent more bugs than when you can carelessly `?`-annotate your way through a dozen lines without any equivalents of `finally { ... }` anywhere.
Re:Lies we tell ourselves to keep using Golang
by Arnavion on Thursday November 28, 2024 @11:49PM
(#42270906)
>...but you're not choosing to write the `throws FooException`?
Now read the rest of the comment after where you stopped reading. Or reread https://news.ycombinator.com/item?id=42249525 I'm tired of repeating myself.
No. You're choosing to write the `?` there to bubble up the error. It's a compiler error if you forget it. Whereas with `throws FooException` you only get forced to remember it the first time, and after that you're allowed to forget it.