From 195d55078111fdedc73538a7025d44e4126ce61c Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Mon, 26 May 2025 10:37:11 +0200 Subject: [PATCH] Remove old thiserror --- Cargo.toml | 3 --- dbpg/src/err.rs | 14 ++++++-------- dbpg/src/findaddr.rs | 15 +++++++-------- dbpg/src/pool.rs | 19 +++++++++---------- dbpg/src/schema.rs | 15 +++++++-------- dbpg/src/seriesbychannel.rs | 31 +++++++++++++------------------ dbpg/src/testerr.rs | 15 +++++++-------- 7 files changed, 49 insertions(+), 63 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index db4bf9a..4ebf8ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,3 @@ debug-assertions = false lto = "thin" codegen-units = 64 incremental = true - -[patch.crates-io] -thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" } diff --git a/dbpg/src/err.rs b/dbpg/src/err.rs index a922d4e..e15fda6 100644 --- a/dbpg/src/err.rs +++ b/dbpg/src/err.rs @@ -1,8 +1,6 @@ -use err::thiserror; -use err::ThisError; - -#[derive(Debug, ThisError)] -#[cstm(name = "Postgres")] -pub enum Error { - Postgres(#[from] tokio_postgres::Error), -} +autoerr::create_error_v1!( + name(Error, "Postgres"), + enum variants { + Postgres(#[from] tokio_postgres::Error), + }, +); diff --git a/dbpg/src/findaddr.rs b/dbpg/src/findaddr.rs index a46e387..6ca604b 100644 --- a/dbpg/src/findaddr.rs +++ b/dbpg/src/findaddr.rs @@ -1,15 +1,14 @@ use crate::conn::PgClient; -use err::thiserror; -use err::ThisError; use log::*; use std::net::SocketAddrV4; -#[derive(Debug, ThisError)] -#[cstm(name = "PgFindAddr")] -pub enum Error { - Postgres(#[from] tokio_postgres::Error), - IocAddrNotFound, -} +autoerr::create_error_v1!( + name(Error, "PgFindAddr"), + enum variants { + Postgres(#[from] tokio_postgres::Error), + IocAddrNotFound, + }, +); #[allow(unused)] async fn __find_channel_addr(backend: &str, name: String, pg: &PgClient) -> Result, Error> { diff --git a/dbpg/src/pool.rs b/dbpg/src/pool.rs index 9e5f26f..6204bd9 100644 --- a/dbpg/src/pool.rs +++ b/dbpg/src/pool.rs @@ -3,19 +3,18 @@ use async_channel::Receiver; use async_channel::RecvError; use async_channel::SendError; use async_channel::Sender; -use err::thiserror; -use err::ThisError; use log::*; use netpod::Database; -#[derive(Debug, ThisError)] -#[cstm(name = "PgPool")] -pub enum Error { - Postgres(#[from] tokio_postgres::Error), - EndOfPool, - ChannelRecv(#[from] RecvError), - ChannelSend, -} +autoerr::create_error_v1!( + name(Error, "PgPool"), + enum variants { + Postgres(#[from] tokio_postgres::Error), + EndOfPool, + ChannelRecv(#[from] RecvError), + ChannelSend, + }, +); impl From for Error { fn from(value: crate::err::Error) -> Self { diff --git a/dbpg/src/schema.rs b/dbpg/src/schema.rs index 0f4b0f5..0ddc608 100644 --- a/dbpg/src/schema.rs +++ b/dbpg/src/schema.rs @@ -1,14 +1,13 @@ use crate::conn::PgClient; -use err::thiserror; -use err::ThisError; use log::*; -#[derive(Debug, ThisError)] -#[cstm(name = "PgSchema")] -pub enum Error { - Postgres(#[from] tokio_postgres::Error), - LogicError(String), -} +autoerr::create_error_v1!( + name(Error, "PgSchema"), + enum variants { + Postgres(#[from] tokio_postgres::Error), + LogicError(String), + }, +); impl Error { pub fn from_logic_msg(msg: T) -> Self diff --git a/dbpg/src/seriesbychannel.rs b/dbpg/src/seriesbychannel.rs index 65071b3..eab5e64 100644 --- a/dbpg/src/seriesbychannel.rs +++ b/dbpg/src/seriesbychannel.rs @@ -3,8 +3,6 @@ use async_channel::Sender; use chrono::DateTime; use chrono::Utc; use core::fmt; -use err::ThisError; -use err::thiserror; use futures_util::Future; use futures_util::TryFutureExt; use log::*; @@ -16,7 +14,6 @@ use netpod::Shape; use serde::Serialize; use series::SeriesId; use std::pin::Pin; -use std::sync::Arc; use std::time::Duration; use std::time::Instant; use taskrun::tokio; @@ -42,21 +39,19 @@ macro_rules! trace3 { }; } -#[derive(Debug, ThisError)] -#[cstm(name = "PgSeries")] -pub enum Error { - Postgres(#[from] tokio_postgres::Error), - CreateSeriesFail, - SeriesMissing, - ChannelError, - #[error("DbConsistencySeries({0})")] - DbConsistencySeries(String), - #[error("ScalarType({0})")] - ScalarType(i32), - Shape, - #[error("SeriesKind({0})")] - SeriesKind(i16), -} +autoerr::create_error_v1!( + name(Error, "PgSeries"), + enum variants { + Postgres(#[from] tokio_postgres::Error), + CreateSeriesFail, + SeriesMissing, + ChannelError, + DbConsistencySeries(String), + ScalarType(i32), + Shape, + SeriesKind(i16), + }, +); impl From for Error { fn from(value: crate::err::Error) -> Self { diff --git a/dbpg/src/testerr.rs b/dbpg/src/testerr.rs index 9eca904..b9a9314 100644 --- a/dbpg/src/testerr.rs +++ b/dbpg/src/testerr.rs @@ -1,5 +1,3 @@ -use err::thiserror; -use err::ThisError; use std::fmt; #[derive(Debug)] @@ -15,12 +13,13 @@ impl fmt::Display for TestError { impl std::error::Error for TestError {} -#[derive(Debug, ThisError)] -#[cstm(name = "PgTestErr")] -enum Error { - Postgres(#[from] tokio_postgres::Error), - Dummy(#[from] TestError), -} +autoerr::create_error_v1!( + name(Error, "PgTestErr"), + enum variants { + Postgres(#[from] tokio_postgres::Error), + Dummy(#[from] TestError), + }, +); #[test] fn err_msg_01() {