Function mz_ore::panic::set_abort_on_panic
source ยท pub fn set_abort_on_panic()
Expand description
Instructs the entire process to abort if any thread panics.
By default, when a thread panics in Rust, only that thread is affected, and other threads continue running unaffected. This is a bad default. In almost all programs, thread panics are unexpected, unrecoverable, and leave the overall program in an invalid state. It is therefore typically less confusing to abort the entire program.
For example, consider a simple program with two threads communicating through a channel, where the first thread is waiting for the second thread to send a value over the channel. If the second thread panics, the first thread will block forever for a value that will never be produced. Blocking forever will be more confusing to the end user than aborting the program entirely.
Computations in which a panic is expected can use the special
catch_unwind
function in this module to recover. Note that the
catch_unwind
function in the standard library is not compatible with
this function.