3 ms·
Oh, I know about this already. Trouble is, panics aren't supposed to cross module boundaries. "The convention in the Go libraries is that even when a package u
by barrkel 15y ago
Oh, I know about this already. Trouble is, panics aren't supposed to cross module boundaries.
"The convention in the Go libraries is that even when a package uses panic internally, its external API still presents explicit error return values"
http://blog.golang.org/2010/08/defer-panic-and-recover.html http://blog.golang.org/2010/08/defer-panic-and-recover.html
But crossing interfaces between modules is, IMO, core to exceptions. They're ideally suited to communicating the underlying cause of failure from the depths of the system to the top-most loop (usually a request/response dispatcher or UI event loop), where the error message can be logged or shown to the user, as required, indicating the nature of the failure.
I expounded further on this point a few years ago, related to Java's misadventure with checked exceptions, but also relevant to module crossing:
http://cafe.elharo.com/programming/bruce-eckel-is-wrong/#comment-476790 http://cafe.elharo.com/programming/bruce-eckel-is-wrong/#com...
- ericbb 15y agoI won't get into the interface-crossing issue except to say that exceptions to the convention do exist. For example: http://golang.org/pkg/regexp/#MustCompile http://golang.org/pkg/regexp/#MustCompile