Struct CrashHandler

Source
pub struct CrashHandler { /* private fields */ }
Expand description

A wrapper around a process closure that handles crashes by running the closure as a subprocess and invoking a crash handler closure if the subprocess fails.

Implementations§

Source§

impl CrashHandler

Source

pub fn new() -> Self

Create a new crash reporter with default settings.

Source

pub fn with_process(process: impl Fn() + 'static) -> Self

Create a new crash reporter from the given closure that runs a process.

Source

pub fn child_flag(self, flag: impl Into<String>) -> Self

Sets the command line flag that identifies a child process.

Source

pub fn crash_handler( self, crash_handler: impl Fn(Output) -> Result<(), Box<dyn Error>> + 'static, ) -> Self

Sets the crash handler that is called when the process fails.

Source

pub fn backtrace(self) -> Self

Sets the value of the RUST_BACKTRACE environment variable in the subprocess to 1.

Source

pub fn full_backtrace(self) -> Self

Sets the value of the RUST_BACKTRACE environment variable in the subprocess to full.

Source

pub fn run(&self) -> Result<bool, Box<dyn Error>>

Runs the configured process as a subprocess and handle crashes if the child flag is not present, otherwise run the process normally.

§Returns
  • Ok(true) if the process ran successfully without errors.
  • Ok(false) if there was an error in the process (that was handled).
  • Err if there was an error spawning the process or handling an error in the process.

Trait Implementations§

Source§

impl Default for CrashHandler

Source§

fn default() -> Self

Create a new crash reporter with default settings (a process that prints “Hello, world!”, “–cortex-bypass” bypass flag, a crash handler that prints the status code and error message using eprintln!, and RUST_BACKTRACE=full).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.