Re:New in Go 1.20: wrapping multiple errors
by kaba0 on Sunday December 11, 2022 @03:44PM
(#33947288)
Exceptions are much better, especially checked ones (which are analogous to Rust-style result types).
[ Parent
| on HN ]
Re:New in Go 1.20: wrapping multiple errors
by cjglo on Monday December 12, 2022 @11:17AM
(#33956388)
Not analogous.
Rust-style result types continue the normal control flow.
Any exception thrown deep into a function can be very hard to debug. The normal line of execution is stopped, even without a return, and if it’s a checked exception it can “bubble up” to higher functions despite nothing signifying a return, just a marker saying somewhere this can throw an exception.
Exceptions are terrible.
Re:New in Go 1.20: wrapping multiple errors
by kaba0 on Tuesday December 13, 2022 @05:38AM
(#33966992)
This is literally the exact same thing. Exceptions are not gotos. They bubble up one method at a time, and can be handled at any level you want. Matching on a result type is literally the same thing as putting in inside a try-catch block. Putting a ? macro at the end is literally the default behavior. You can handle it on as tight/wide scope as you wish, plus you also get a must-have stacktrace — so your debugging is just looking at where the exception originated from.