r/ProgrammerHumor • • Oct 17 '26

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.6k Upvotes

524 comments sorted by

View all comments

Show parent comment

40

u/mathisntmathingsad Oct 17 '26

Yeah, the only reason you should try to catch a panic is if you're making something that calls user-provided code unavoidably (i.e. an async runtime)

20

u/shizzy0 Oct 17 '26

Yeah, we catch panics in tests but that’s about it.

16

u/Loading_M_ Oct 18 '26

I work on a library that does catch panics from user code. It's a web framework, and catches panics in user request handlers to return a 500 error to the client. This error is explicitly not overridable (every other default error can be replaced, but not this one), since we don't want you to panic in the first place.