From 6f9662332222223879e2d356466b6d2ef48897a3 Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Tue, 3 Jun 2025 12:25:02 +0200 Subject: [PATCH] Retire old error macro --- Cargo.toml | 2 +- src/lib.rs | 45 ++++++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 08b7e3c..9652ccb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,4 +19,4 @@ url = { version = "2.5.3", default-features = false } regex = "1.9.1" http = "1.0.0" anyhow = "1.0" -autoerr = "0.0.3" +autoerr = "0.0" diff --git a/src/lib.rs b/src/lib.rs index bc7264d..8d2a36c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -506,30 +506,32 @@ pub trait ToPublicError: std::error::Error + Send { #[cfg(test)] mod test { - use super::*; + #![allow(unused)] + // use super::Serialize; - #[derive(Debug, ThisError, Serialize, Deserialize)] - #[cstm(name = "SomeErrorEnumA")] - enum SomeErrorEnumA { - BadCase, - WithStringContent(String), - // #[error("bad: {0}")] - WithStringContentFmt(String), - } + autoerr::create_error_v1!( + name(SomeErrorEnumA, "SomeErrorEnumA"), + enum variants { + BadCase, + WithStringContent(String), + WithStringContentFmt(String), + }, + ); - #[derive(Debug, ThisError, Serialize, Deserialize)] - #[cstm(name = "SomeErrorEnumB0")] - enum SomeErrorEnumB0 { - FromA(#[from] SomeErrorEnumA), - } + autoerr::create_error_v1!( + name(SomeErrorEnumB0, "SomeErrorEnumB0"), + enum variants { + FromA(#[from] SomeErrorEnumA), + }, + ); - #[derive(Debug, ThisError, Serialize, Deserialize)] - #[cstm(name = "SomeErrorEnumB1")] - enum SomeErrorEnumB1 { - FromA(#[from] SomeErrorEnumA), - #[error("caffe")] - Caffe(SomeErrorEnumA), - } + autoerr::create_error_v1!( + name(SomeErrorEnumB1, "SomeErrorEnumB1"), + enum variants { + FromA(#[from] SomeErrorEnumA), + Caffe(SomeErrorEnumA), + }, + ); fn failing_a_00() -> Result<(), SomeErrorEnumA> { Err(SomeErrorEnumA::BadCase) @@ -576,6 +578,7 @@ mod test { assert_eq!(s, "SomeErrorEnumB0::FromA(SomeErrorEnumA::BadCase)"); } + #[cfg(target_abi = "x32")] #[test] fn error_handle_b0_user_00() { use thiserror::UserErrorClass;