|
|
|
|
|
by frodowtf
950 days ago
|
|
`panic` has nothing to do with error handling though. If you use it, you know that your callers cannot recover from it. Throwing an exception implicitly delegates error handling back to the caller, but they are not even notified about it. (talking about OCaml) |
|
Some frameworks catch panics automatically. For example, in the Actix web framework, if you panic in an HTTP response the panic will be catchee, so it won't bring the whole server down.
Also, by default a panic will terminate only the current thread, which is a major footgun: you now need to reason about what you program will do after some bug or unforseen circunstance happened somewhere in the code and made you program misbehave. Which leads to slightly insane things like lock poisoning.
It's more sane to compile with panic=abort, but that's not the default and it means that on panic you won't release resources (which aren't just allocated memory to be clear)