3 ms·
I've never heard of anyone using panic for exception-style recovery. That's anathema to the whole idea of Result<T,V>. But I suppose if it's possible, it will b
by jvanderbot 1y ago
I've never heard of anyone using panic for exception-style recovery. That's anathema to the whole idea of Result<T,V>. But I suppose if it's possible, it will be normal for someone.
- Zambyte 1y agoI'm not as familiar with the Rust ecosystem, but I know it is used all the time in Go. For example, the standard http server library wraps user provided endpoint handler functions with panic handlers.
- nicoburns 1y agoIs that used for application-level errors though? Rust web servers do that too, but it is used a fallback to avoid bringing down the whole server due to an unexpected crash. It is not a mechanism you would use intentionally.
- dhruvrajvanshi 1y agoI suppose it's a matter of perspective but I don't see returning a 500 as "Recovering from the error". The user's request has still failed. It just hasn't taken down the server. IMO this is still fine.
- Zambyte 1y agoIt is quite literally using the "recover" function in go, so I think it's accurate to call it "recovering". > this is fine I didn't mention the merit, just that it is exception style control flow.
- Zambyte 1y agoReading my top level comment again, I realized I did refer to the Zig way as "nice" relative to the exception style control flow.