Skip to main content

catch

Function catch 

Source
pub fn catch<R>(work: impl FnOnce() -> R) -> Result<R, String>
Expand description

Runs work, and returns the message of the panic that ended it instead of its result. The panic hook has reported the panic already.

The state that work changed may be half-changed after a panic, so the caller must not rely on it, such as by failing what owns it.

§Errors

Returns the panic’s message when work panicked.