I am new to Rust and have come to understand Rust defaults to panics and not exceptions.
I have a rust project that depends on external libraries.
I have handled all unwraps and ?
's in my code using match
statements, but I am not sure how to handle a panic
by external libraries.
In other languages I would just catch an exception thrown by the library.
As Rust defaults to panics, the libraries don't return an exception but panic
and thus abort execution of the thread.
I would ideally want to log and continue execution, not panic and abort.
I have tried the following:
catch_unwind
, but this looks like something I can't use on an external library.log-panics
crate, which logs the panic using a panic hook. I am able to log the panic, but not prevent aborts.