Expand description

This crate provides a wrapper around an error that includes the location of the error.

use std::error::Error;
use std::panic::Location;
use std::sync::Arc;
use torrust_tracker_located_error::{Located, LocatedError};

#[derive(thiserror::Error, Debug)]
enum TestError {
    #[error("Test")]
    Test,
}

#[track_caller]
fn get_caller_location() -> Location<'static> {
    *Location::caller()
}

let e = TestError::Test;

let b: LocatedError<TestError> = Located(e).into();
let l = get_caller_location();

assert!(b.to_string().contains("Test, src/lib.rs"));

Credits

https://stackoverflow.com/questions/74336993/getting-line-numbers-with-when-using-boxdyn-stderrorerror

Structs

  • A generic wrapper around an error.
  • A wrapper around an error that includes the location of the error.