#p2p #helper #bittorrent-tracker #location #debugging #torrent-indexer #error

torrust-tracker-located-error

A library to provide error decorator with the location and the source of the original error

6 releases (1 stable)

3.0.0 Oct 3, 2024
3.0.0-alpha.11 Sep 18, 2023
3.0.0-alpha.3 Jul 10, 2023
3.0.0-alpha.2 Apr 13, 2023
3.0.0-alpha.1 Mar 17, 2023

#5 in #bittorrent-tracker

Download history 2/week @ 2024-12-18 1/week @ 2025-01-22 8/week @ 2025-02-05 3/week @ 2025-02-12 3/week @ 2025-02-26

393 downloads per month
Used in 4 crates (2 directly)

AGPL-3.0-only

15KB
88 lines

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


Torrust Tracker Located Error

A library to provide an error decorator with the location and the source of the original error.

Documentation

Crate documentation.

License

The project is licensed under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE.

Dependencies

~295–410KB