Re:A minimal blog engine written in Go, compatible with Ghos...
by burntsushi on Saturday April 25, 2015 @08:32PM
(#9440057)
I'm pretty sure you've misunderstood. Did you read the code I linked you to? Look at how it handles errors internally. Go's standard JSON decoder isn't going to crash your program if it fails to parse JSON---that would be disastrous. It exposes regular errors to the user. But internally, it uses panic/recover because it elides a lot of manual error checking.
Re:A minimal blog engine written in Go, compatible with Ghos...
by thirsteh on Saturday April 25, 2015 @08:12PM
(#9440008)
Panic/recover is no problem as long as it does not traverse API boundaries, i.e. affects the user of your package, unless it really is a "fatal user error" in a function that wouldn't otherwise return an error.
Panic/recover are usually meant to catch "coding" and "assertion"-type errors (null pointers, array overflows, etc), not runtime errors. The latter is what the "error" values are used for.