pub struct Panic { /* private fields */ }Expand description
Panic info gathered as one record
Contains panic’s location, message or raw payload, and backtrace, if collected
Implementations§
Source§impl Panic
impl Panic
Sourcepub fn location(&self) -> Option<&OwnedLocation>
pub fn location(&self) -> Option<&OwnedLocation>
Panic location, if original std::panic::PanicHookInfo provided one
Sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
Original panic message which was supplied to std::panic! macro
If panic was raised using std::panic::panic_any with non-string payload,
this function returns substitute message
Sourcepub fn raw_payload(&self) -> Option<&Box<dyn Any + Send + 'static>>
pub fn raw_payload(&self) -> Option<&Box<dyn Any + Send + 'static>>
Raw panic payload if it wasn’t recognized as string-like message and converted to it
Sourcepub fn into_raw_payload(self) -> Box<dyn Any + Send + 'static>
pub fn into_raw_payload(self) -> Box<dyn Any + Send + 'static>
Transforms panic info into raw panic payload. If it’s a string-like message, it gets re-wrapped again.
Useful when you need something like rethrowing panic
Sourcepub fn display_with_backtrace(&self) -> impl Display + '_
pub fn display_with_backtrace(&self) -> impl Display + '_
Produces std::fmt::Display’able object
which displays panic’s message, location and short backtrace, if captured
Sourcepub fn display_with_backtrace_style(
&self,
style: BacktraceStyle,
) -> impl Display + '_
pub fn display_with_backtrace_style( &self, style: BacktraceStyle, ) -> impl Display + '_
Produces std::fmt::Display’able object
which displays panic’s message, location and backtrace, if captured, with specified style
Trait Implementations§
Source§impl Error for Panic
impl Error for Panic
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()