6 ms·
Panic() should only be used to signal either programmer error, or truly panic-worthy situations where state is so messed up that crashing is the only good optio
by luriel 14y ago
Panic() should only be used to signal either programmer error, or truly panic-worthy situations where state is so messed up that crashing is the only good option.
Put another way: when you call an API correctly, it should be safe to assume it will never panic().
Panic/recover can be used in rare occasions within libraries to do more exception-ish style error handling, but those panics should never be allowed to escape and cross API boundaries.