3 ms·
> Panics do not need to be caught and handled. You can (and should) transform panics into abort. I think this strong stance needs some justification, especiall
by mwcampbell 5y ago
> Panics do not need to be caught and handled. You can (and should) transform panics into abort.
I think this strong stance needs some justification, especially since it's not the default in Rust.
- lanstin 5y agoIt is in Go Lang which shares error handling philosophy with GP.
- ziml77 5y agoGo panics do not simply abort. "For a real-world example of panic and recover, see the json package from the Go standard library. It encodes an interface with a set of recursive functions. If an error occurs when traversing the value, panic is called to unwind the stack to the top-level function call, which recovers from the panic and returns an appropriate error value (see the ‘error’ and ‘marshal’ methods of the encodeState type in encode.go)." From https://go.dev/blog/defer-panic-and-recover https://go.dev/blog/defer-panic-and-recover
- lanstin 5y agoBut philosophically, they should just abort.