2 个版本
新 3.0.0-alpha.12 | 2024 年 8 月 13 日 |
---|---|
3.0.0-alpha.2 | 2023 年 10 月 15 日 |
#92 in #library
81 每月下载量
用于 torrust-index
15KB
87 行代码(不含注释)
Torrust Tracker Located Error
一个提供带有错误位置和原始错误来源的错误装饰器的库。
文档
包文档.
许可
该项目遵守 GNU AFFERO GENERAL PUBLIC LICENSE 的条款。
lib.rs
:
此包提供了一个错误包装器,其中包含错误的位置。
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"));
鸣谢
依赖项
~1.7–2.5MB
~43K SLoC