4 ms·
There's a range of other options for error handling between a global errno and wrapping every lines in try-catch... Many languages make it idiomatic for functi
by tredre3 2y ago
There's a range of other options for error handling between a global errno and wrapping every lines in try-catch...
Many languages make it idiomatic for functions to return a value or error (Rust, Go, modern C++) so that you can access a human-friendly error on failure.
https://doc.rust-lang.org/std/result/ https://doc.rust-lang.org/std/result/
https://go.dev/doc/tutorial/handle-errors https://go.dev/doc/tutorial/handle-errors
https://en.cppreference.com/w/cpp/utility/expected https://en.cppreference.com/w/cpp/utility/expected (there's also std::variant and std::optional that can get you there since C++17)
- kaba0 2y agoGo pretty much uses a global errno, it’s literally analogous, and is a terrible language from an error handling perspective, that failed to learn anything since C.