from_boxed_error

Function from_boxed_error 

Source
pub fn from_boxed_error(
    boxed_err: Box<dyn Error + Send + Sync + 'static>,
) -> Error
Expand description

Convert a boxed error into an okerr/anyhow Error.

ยงExample:

use okerr::{Result, from_boxed_error};

fn returns_eyre_error() -> eyre::Result<i32> {
    Err(eyre::eyre!("eyre error"))
}

fn convert_eyre() -> Result<i32> {
    returns_eyre_error().map_err(|e| from_boxed_error(e.into()))
}

let result = convert_eyre();
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("eyre error"));