3 ms·
> How does anyone on the stack above handle this error? For a web application, you respond to the request with 5xx error. Applications do many things. A degrad
by phamilton 3y ago
> How does anyone on the stack above handle this error?
For a web application, you respond to the request with 5xx error.
Applications do many things. A degraded state (e.g. a single endpoint being broken) is often preferable to a full crash. It's very little effort to opt in to panics by calling unwrap(). It's a lot of effort to recover from panics. Let me, as the caller, make that decision.
- ramranch 3y agoBut any standard web framework already would use a panic handler to turn a panic within application code to a 5xx error.
- throwway3423 3y ago[flagged]
- phamilton 3y agoHere's a discussion on actix-web and panic handlers: https://github.com/actix/actix-web/issues/1501 https://github.com/actix/actix-web/issues/1501 Some technical limits, a lot of cultural opposition. While it is possible to have a panic handler, it's generally viewed as a bad idea. Not everything is UnwindSafe, there are limits to how much a panic handler can do, concerns about memory leaks. Again, the caller can turn it into a panic easily enough if that's what they want. leave the decision in their hands.