3 ms·
Well, panics should not be used for recoverable error handing in Rust. There's no guarantee turning off panics in favor of aborts wont break the assumptions of
by nixpulvis 7y ago
Well, panics should not be used for recoverable error handing in Rust. There's no guarantee turning off panics in favor of aborts wont break the assumptions of some library. That library should probably break tho, since as you said, panics aren't meant to emulate application logic exceptions.
use std::panic::catch_unwind;
fn main() {
let err = catch_unwind(|| { panic!("B") });
println!("Look ma, recoverable error handing! {:?}", err);
}
- steveklabnik 7y agoYes, libraries that do this are encouraged to configure their Cargo.toml so that compilation will fail if someone turns on aborts.