Re:Error handling in Go web apps shouldn't be so awkward
by riwsky on Tuesday January 09, 2024 @09:23PM
(#38935359)
Rust-the-language, maybe—but Rust-the-ecosystem makes heavy use of magic crates like `thiserror` and `anyhow`. I’m not saying it’s a better or worse philosophy, but it’s certainly a different philosophy.
[ Parent
| on HN ]
Re:Error handling in Go web apps shouldn't be so awkward
by kelnos on Wednesday January 10, 2024 @12:16AM
(#38936502)
thiserror and anyhow exist for ergonomic purposes (and enhance the experience of using the question-mark operator). Libraries shouldn't be leaking thiserror or anyhow types into their public interface. If they are, that's bad design.
Re:Error handling in Go web apps shouldn't be so awkward
by jeremyloy_wt on Tuesday January 09, 2024 @09:45PM
(#38935494)
thiserror and anyhow are hardly magic.
The former is just macros for error definition
The latter is just a wrapper around box dyn error
Re:Error handling in Go web apps shouldn't be so awkward
by riwsky on Wednesday January 10, 2024 @03:47PM
(#38942858)
“Magic” isn’t a rigorously defined term, so let’s ignore it. Support for macros is a huge philosophical difference between Rust and Go.
Re:Error handling in Go web apps shouldn't be so awkward
by jeremyloy_wt on Wednesday January 10, 2024 @05:07PM
(#38944027)
I disagree in the context of error handling.
The go ecosystem frequently utilizes `go generate` to handle boilerplate code generation. That’s the exact same way `thiserror` utilizes macros to generate plain error structs. While macros can do more, in this case it’s the same.