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
Structs§
- Located
- A generic wrapper around an error.
- Located
Error - A wrapper around an error that includes the location of the error.