From 2f89c969cdf86d7db67296c404860cfda961487f Mon Sep 17 00:00:00 2001 From: Dominik Werder Date: Thu, 7 Nov 2024 18:26:02 +0100 Subject: [PATCH] Moved err crate --- crates/commonio/Cargo.toml | 2 +- crates/commonio/src/commonio.rs | 1 + crates/commonio/src/ringbuf.rs | 1 + crates/daqbuf-redis/Cargo.toml | 2 +- crates/daqbuffer/Cargo.toml | 2 +- crates/daqbuffer/src/bin/daqbuffer.rs | 2 +- crates/daqbuffer/src/err.rs | 6 +- crates/daqbuffer/src/fetch.rs | 4 +- crates/daqbufp2/Cargo.toml | 2 +- crates/daqbufp2/src/client.rs | 4 +- crates/daqbufp2/src/daqbufp2.rs | 2 +- crates/daqbufp2/src/err.rs | 6 +- crates/daqbufp2/src/nodes.rs | 2 +- crates/daqbufp2/src/test/api1.rs | 2 +- .../daqbufp2/src/test/api1/data_api_python.rs | 2 +- crates/daqbufp2/src/test/api4/binnedjson.rs | 2 +- crates/daqbufp2/src/test/api4/common.rs | 2 +- crates/daqbufp2/src/test/api4/eventsjson.rs | 2 +- crates/daqbufp2/src/test/api4/pulseiddiff.rs | 2 +- crates/daqbufp2/src/test/archapp.rs | 2 +- crates/daqbufp2/src/test/binnedjson.rs | 2 +- crates/daqbufp2/src/test/timeweightedjson.rs | 2 +- crates/dbconn/Cargo.toml | 4 +- crates/dbconn/src/channelconfig.rs | 1 + crates/dbconn/src/channelinfo.rs | 1 + crates/dbconn/src/dbconn.rs | 1 + crates/dbconn/src/scan.rs | 1 + crates/dbconn/src/search.rs | 1 + crates/dbconn/src/worker.rs | 1 + crates/disk/Cargo.toml | 2 +- crates/disk/src/aggtest.rs | 1 + crates/disk/src/binnedstream.rs | 1 + crates/disk/src/channelconfig.rs | 1 + crates/disk/src/dataopen.rs | 1 + crates/disk/src/decode.rs | 1 + crates/disk/src/disk.rs | 1 + crates/disk/src/eventchunker.rs | 1 + crates/disk/src/eventchunkermultifile.rs | 1 + crates/disk/src/gen.rs | 1 + crates/disk/src/index.rs | 1 + crates/disk/src/paths.rs | 1 + crates/disk/src/raw/conn.rs | 1 + crates/disk/src/read3.rs | 1 + crates/disk/src/read4.rs | 1 + crates/dq/Cargo.toml | 6 +- crates/dq/src/bin/daq-convert.rs | 1 + crates/dq/src/bin/dq.rs | 1 + crates/err/Cargo.toml | 28 - crates/err/src/lib.rs | 610 ------------------ crates/httpclient/Cargo.toml | 2 +- crates/httpclient/src/httpclient.rs | 1 + crates/httpret/Cargo.toml | 2 +- crates/httpret/src/api1.rs | 1 + crates/httpret/src/api4/accounting.rs | 1 + crates/httpret/src/api4/binned.rs | 3 +- crates/httpret/src/api4/databuffer_tools.rs | 1 + crates/httpret/src/api4/eventdata.rs | 1 + crates/httpret/src/api4/events.rs | 1 + crates/httpret/src/bodystream.rs | 3 +- crates/httpret/src/channelconfig.rs | 46 +- crates/httpret/src/err.rs | 5 +- crates/httpret/src/httpret.rs | 13 +- crates/httpret/src/proxy/api4.rs | 4 +- crates/httpret/src/pulsemap.rs | 14 +- crates/items_0/Cargo.toml | 2 +- crates/items_0/src/collect_s.rs | 1 + crates/items_0/src/items_0.rs | 1 + crates/items_0/src/scalar_ops.rs | 1 + crates/items_0/src/streamitem.rs | 1 + crates/items_0/src/transform.rs | 1 + crates/items_2/Cargo.toml | 2 +- crates/items_2/src/binning/container_bins.rs | 1 + .../items_2/src/binning/container_events.rs | 1 + crates/items_2/src/binning/test/events00.rs | 1 + .../binning/timeweight/timeweight_events.rs | 1 + .../timeweight/timeweight_events_dyn.rs | 11 +- crates/items_2/src/binsdim0.rs | 1 + crates/items_2/src/binsxbindim0.rs | 1 + crates/items_2/src/channelevents.rs | 1 + crates/items_2/src/empty.rs | 1 + crates/items_2/src/eventfull.rs | 1 + crates/items_2/src/eventsdim0.rs | 1 + crates/items_2/src/eventsdim0enum.rs | 1 + crates/items_2/src/eventsdim1.rs | 1 + crates/items_2/src/eventsxbindim0.rs | 1 + crates/items_2/src/framable.rs | 1 + crates/items_2/src/frame.rs | 1 + crates/items_2/src/items_2.rs | 1 + crates/netpod/Cargo.toml | 2 +- crates/netpod/src/channelstatus.rs | 2 + crates/netpod/src/netpod.rs | 8 +- crates/netpod/src/query.rs | 2 + crates/netpod/src/query/api1.rs | 8 +- crates/netpod/src/query/datetime.rs | 1 + crates/netpod/src/range/evrange.rs | 1 + crates/netpod/src/streamext.rs | 1 + crates/netpod/src/ttl.rs | 1 + crates/nodenet/Cargo.toml | 2 +- crates/nodenet/src/channelconfig.rs | 1 + crates/nodenet/src/client.rs | 1 + crates/nodenet/src/configquorum.rs | 1 + crates/nodenet/src/conn.rs | 1 + crates/nodenet/src/conn/test.rs | 1 + crates/nodenet/src/scylla.rs | 3 +- crates/parse/Cargo.toml | 3 +- crates/parse/src/api1_parse.rs | 1 + crates/parse/src/channelconfig.rs | 1 + crates/scyllaconn/Cargo.toml | 4 +- crates/scyllaconn/src/accounting/toplist.rs | 1 + crates/scyllaconn/src/accounting/totals.rs | 1 + crates/scyllaconn/src/conn.rs | 1 + crates/scyllaconn/src/errconv.rs | 1 + crates/scyllaconn/src/events.rs | 3 +- crates/scyllaconn/src/events2/events.rs | 3 +- crates/scyllaconn/src/events2/firstbefore.rs | 1 + crates/scyllaconn/src/events2/mergert.rs | 1 + crates/scyllaconn/src/events2/msp.rs | 3 +- crates/scyllaconn/src/events2/prepare.rs | 1 + crates/scyllaconn/src/schema.rs | 1 + crates/scyllaconn/src/scyllaconn.rs | 2 +- crates/scyllaconn/src/status.rs | 1 + crates/scyllaconn/src/worker.rs | 1 + crates/taskrun/Cargo.toml | 2 +- crates/taskrun/src/taskrun.rs | 1 + 124 files changed, 191 insertions(+), 738 deletions(-) delete mode 100644 crates/err/Cargo.toml delete mode 100644 crates/err/src/lib.rs diff --git a/crates/commonio/Cargo.toml b/crates/commonio/Cargo.toml index 944b18f..bbf9d0b 100644 --- a/crates/commonio/Cargo.toml +++ b/crates/commonio/Cargo.toml @@ -17,7 +17,7 @@ chrono = "0.4" async-channel = "1.9.0" parking_lot = "0.12" crc32fast = "1.2" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } taskrun = { path = "../taskrun" } netpod = { path = "../netpod" } items_0 = { path = "../items_0" } diff --git a/crates/commonio/src/commonio.rs b/crates/commonio/src/commonio.rs index 51e1df6..987fbc3 100644 --- a/crates/commonio/src/commonio.rs +++ b/crates/commonio/src/commonio.rs @@ -1,6 +1,7 @@ pub mod ringbuf; use async_channel::Sender; +use daqbuf_err as err; use err::ErrStr; use err::Error; use futures_util::StreamExt; diff --git a/crates/commonio/src/ringbuf.rs b/crates/commonio/src/ringbuf.rs index 197fed3..7550959 100644 --- a/crates/commonio/src/ringbuf.rs +++ b/crates/commonio/src/ringbuf.rs @@ -1,6 +1,7 @@ use crate::read; use crate::seek; use crate::StatsChannel; +use daqbuf_err as err; use err::Error; use netpod::log::*; use std::borrow::BorrowMut; diff --git a/crates/daqbuf-redis/Cargo.toml b/crates/daqbuf-redis/Cargo.toml index cfdaf2e..ca8bf38 100644 --- a/crates/daqbuf-redis/Cargo.toml +++ b/crates/daqbuf-redis/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } taskrun = { path = "../taskrun" } redis = { version = "0.26.1", features = [] } diff --git a/crates/daqbuffer/Cargo.toml b/crates/daqbuffer/Cargo.toml index 296796f..7541c47 100644 --- a/crates/daqbuffer/Cargo.toml +++ b/crates/daqbuffer/Cargo.toml @@ -14,7 +14,7 @@ serde_yaml = "0.9.27" chrono = "0.4.31" url = "2.5.0" clap = { version = "4.5.7", features = ["derive", "cargo"] } -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } taskrun = { path = "../taskrun" } netpod = { path = "../netpod" } disk = { path = "../disk" } diff --git a/crates/daqbuffer/src/bin/daqbuffer.rs b/crates/daqbuffer/src/bin/daqbuffer.rs index 2c846b9..3ada2f4 100644 --- a/crates/daqbuffer/src/bin/daqbuffer.rs +++ b/crates/daqbuffer/src/bin/daqbuffer.rs @@ -2,10 +2,10 @@ use chrono::DateTime; use chrono::Duration; use chrono::Utc; use clap::Parser; +use daqbuf_err::Error; use daqbuffer::cli::ClientType; use daqbuffer::cli::Opts; use daqbuffer::cli::SubCmd; -use err::Error; use netpod::log::*; use netpod::query::CacheUsage; use netpod::NodeConfig; diff --git a/crates/daqbuffer/src/err.rs b/crates/daqbuffer/src/err.rs index 0e70b2c..80de83e 100644 --- a/crates/daqbuffer/src/err.rs +++ b/crates/daqbuffer/src/err.rs @@ -1,14 +1,14 @@ pub trait ErrConv { - fn ec(self) -> Result; + fn ec(self) -> Result; } pub trait Convable: ToString {} impl ErrConv for Result { - fn ec(self) -> Result { + fn ec(self) -> Result { match self { Ok(x) => Ok(x), - Err(e) => Err(::err::Error::from_string(e.to_string())), + Err(e) => Err(daqbuf_err::Error::from_string(e.to_string())), } } } diff --git a/crates/daqbuffer/src/fetch.rs b/crates/daqbuffer/src/fetch.rs index 8273748..439549f 100644 --- a/crates/daqbuffer/src/fetch.rs +++ b/crates/daqbuffer/src/fetch.rs @@ -1,5 +1,5 @@ -use err::thiserror; -use err::ThisError; +use daqbuf_err::thiserror; +use daqbuf_err::ThisError; use futures_util::future; use futures_util::StreamExt; use http::header; diff --git a/crates/daqbufp2/Cargo.toml b/crates/daqbufp2/Cargo.toml index e5f8781..d667c6f 100644 --- a/crates/daqbufp2/Cargo.toml +++ b/crates/daqbufp2/Cargo.toml @@ -21,7 +21,7 @@ serde_json = "1.0" chrono = "0.4" url = "2.2.2" lazy_static = "1.4.0" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } taskrun = { path = "../taskrun" } netpod = { path = "../netpod" } query = { path = "../query" } diff --git a/crates/daqbufp2/src/client.rs b/crates/daqbufp2/src/client.rs index 58fa8e0..16f8525 100644 --- a/crates/daqbufp2/src/client.rs +++ b/crates/daqbufp2/src/client.rs @@ -1,8 +1,8 @@ use crate::err::ErrConv; use chrono::DateTime; use chrono::Utc; +use daqbuf_err::Error; use disk::streamlog::Streamlog; -use err::Error; use futures_util::TryStreamExt; use http::StatusCode; use http::Uri; @@ -118,7 +118,7 @@ pub async fn get_binned( StreamItem::DataItem(_frame) => { // TODO // The expected type nowadays depends on the channel and agg-kind. - err::todo(); + daqbuf_err::todo(); Some(Ok(())) } }, diff --git a/crates/daqbufp2/src/daqbufp2.rs b/crates/daqbufp2/src/daqbufp2.rs index 80b6703..f3a82f2 100644 --- a/crates/daqbufp2/src/daqbufp2.rs +++ b/crates/daqbufp2/src/daqbufp2.rs @@ -4,7 +4,7 @@ pub mod nodes; #[cfg(test)] pub mod test; -use ::err::Error; +use daqbuf_err::Error; use futures_util::TryFutureExt; use netpod::Cluster; use netpod::NodeConfig; diff --git a/crates/daqbufp2/src/err.rs b/crates/daqbufp2/src/err.rs index 8552403..5733b66 100644 --- a/crates/daqbufp2/src/err.rs +++ b/crates/daqbufp2/src/err.rs @@ -1,14 +1,14 @@ pub trait ErrConv { - fn ec(self) -> Result; + fn ec(self) -> Result; } pub trait Convable: ToString {} impl ErrConv for Result { - fn ec(self) -> Result { + fn ec(self) -> Result { match self { Ok(x) => Ok(x), - Err(e) => Err(::err::Error::from_string(e.to_string())), + Err(e) => Err(daqbuf_err::Error::from_string(e.to_string())), } } } diff --git a/crates/daqbufp2/src/nodes.rs b/crates/daqbufp2/src/nodes.rs index e4855cf..0816574 100644 --- a/crates/daqbufp2/src/nodes.rs +++ b/crates/daqbufp2/src/nodes.rs @@ -1,5 +1,5 @@ use crate::spawn_test_hosts; -use err::Error; +use daqbuf_err::Error; use netpod::log::*; use netpod::Cluster; use std::sync::{Arc, Mutex}; diff --git a/crates/daqbufp2/src/test/api1.rs b/crates/daqbufp2/src/test/api1.rs index 3acffbe..f777426 100644 --- a/crates/daqbufp2/src/test/api1.rs +++ b/crates/daqbufp2/src/test/api1.rs @@ -1,7 +1,7 @@ mod data_api_python; use crate::nodes::require_test_hosts_running; -use err::Error; +use daqbuf_err::Error; use futures_util::Future; use httpclient::http_post; use netpod::log::*; diff --git a/crates/daqbufp2/src/test/api1/data_api_python.rs b/crates/daqbufp2/src/test/api1/data_api_python.rs index 0c21054..b53111c 100644 --- a/crates/daqbufp2/src/test/api1/data_api_python.rs +++ b/crates/daqbufp2/src/test/api1/data_api_python.rs @@ -1,6 +1,6 @@ use crate::nodes::require_test_hosts_running; use chrono::Utc; -use err::Error; +use daqbuf_err::Error; use netpod::log::*; use netpod::range::evrange::NanoRange; use netpod::timeunits::MS; diff --git a/crates/daqbufp2/src/test/api4/binnedjson.rs b/crates/daqbufp2/src/test/api4/binnedjson.rs index 23a72e4..13fc373 100644 --- a/crates/daqbufp2/src/test/api4/binnedjson.rs +++ b/crates/daqbufp2/src/test/api4/binnedjson.rs @@ -1,6 +1,6 @@ use crate::nodes::require_test_hosts_running; use chrono::Utc; -use err::Error; +use daqbuf_err::Error; use items_0::test::f32_iter_cmp_near; use items_0::test::f64_iter_cmp_near; use items_0::WithLen; diff --git a/crates/daqbufp2/src/test/api4/common.rs b/crates/daqbufp2/src/test/api4/common.rs index 707e90c..c0e6413 100644 --- a/crates/daqbufp2/src/test/api4/common.rs +++ b/crates/daqbufp2/src/test/api4/common.rs @@ -1,5 +1,5 @@ use chrono::Utc; -use err::Error; +use daqbuf_err::Error; use netpod::log::*; use netpod::AppendToUrl; use netpod::Cluster; diff --git a/crates/daqbufp2/src/test/api4/eventsjson.rs b/crates/daqbufp2/src/test/api4/eventsjson.rs index 4e2e663..8f728c4 100644 --- a/crates/daqbufp2/src/test/api4/eventsjson.rs +++ b/crates/daqbufp2/src/test/api4/eventsjson.rs @@ -1,7 +1,7 @@ use crate::nodes::require_test_hosts_running; use crate::test::api4::common::fetch_events_json; use chrono::Utc; -use err::Error; +use daqbuf_err::Error; use items_0::WithLen; use items_2::eventsdim0::EventsDim0CollectorOutput; use netpod::log::*; diff --git a/crates/daqbufp2/src/test/api4/pulseiddiff.rs b/crates/daqbufp2/src/test/api4/pulseiddiff.rs index 4d6fa0b..e792312 100644 --- a/crates/daqbufp2/src/test/api4/pulseiddiff.rs +++ b/crates/daqbufp2/src/test/api4/pulseiddiff.rs @@ -1,6 +1,6 @@ use crate::nodes::require_test_hosts_running; use crate::test::api4::common::fetch_events_json; -use err::Error; +use daqbuf_err::Error; use items_0::test::f32_iter_cmp_near; use items_0::WithLen; use items_2::eventsdim0::EventsDim0CollectorOutput; diff --git a/crates/daqbufp2/src/test/archapp.rs b/crates/daqbufp2/src/test/archapp.rs index 82b7a00..7a72119 100644 --- a/crates/daqbufp2/src/test/archapp.rs +++ b/crates/daqbufp2/src/test/archapp.rs @@ -1,6 +1,6 @@ #![allow(unused)] use crate::nodes::require_archapp_test_host_running; -use err::Error; +use daqbuf_err::Error; use netpod::f64_close; use netpod::log::*; diff --git a/crates/daqbufp2/src/test/binnedjson.rs b/crates/daqbufp2/src/test/binnedjson.rs index 542423f..9e8bbb9 100644 --- a/crates/daqbufp2/src/test/binnedjson.rs +++ b/crates/daqbufp2/src/test/binnedjson.rs @@ -1,6 +1,6 @@ mod channelarchiver; -use err::Error; +use daqbuf_err::Error; #[test] fn get_sls_archive_1() -> Result<(), Error> { diff --git a/crates/daqbufp2/src/test/timeweightedjson.rs b/crates/daqbufp2/src/test/timeweightedjson.rs index ebd643d..dab5093 100644 --- a/crates/daqbufp2/src/test/timeweightedjson.rs +++ b/crates/daqbufp2/src/test/timeweightedjson.rs @@ -1,6 +1,6 @@ use chrono::DateTime; use chrono::Utc; -use err::Error; +use daqbuf_err::Error; use netpod::log::*; use netpod::query::CacheUsage; use netpod::range::evrange::NanoRange; diff --git a/crates/dbconn/Cargo.toml b/crates/dbconn/Cargo.toml index dd09c68..2fd6417 100644 --- a/crates/dbconn/Cargo.toml +++ b/crates/dbconn/Cargo.toml @@ -10,7 +10,7 @@ path = "src/dbconn.rs" [dependencies] serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tokio-postgres = { version = "0.7.10", features = ["with-chrono-0_4", "with-serde_json-1"] } +tokio-postgres = { version = "0.7.12", features = ["with-chrono-0_4", "with-serde_json-1"] } crc32fast = "1.3.2" byteorder = "1.4" futures-util = "0.3.30" @@ -20,7 +20,7 @@ pin-project = "1" async-channel = "1.9.0" chrono = "0.4.38" regex = "1.10.4" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } netpod = { path = "../netpod" } parse = { path = "../parse" } taskrun = { path = "../taskrun" } diff --git a/crates/dbconn/src/channelconfig.rs b/crates/dbconn/src/channelconfig.rs index b37a462..e977dc4 100644 --- a/crates/dbconn/src/channelconfig.rs +++ b/crates/dbconn/src/channelconfig.rs @@ -1,5 +1,6 @@ use chrono::DateTime; use chrono::Utc; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use netpod::log::*; diff --git a/crates/dbconn/src/channelinfo.rs b/crates/dbconn/src/channelinfo.rs index 77959e9..43dfe8a 100644 --- a/crates/dbconn/src/channelinfo.rs +++ b/crates/dbconn/src/channelinfo.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::thiserror; use err::ThisError; use netpod::ScalarType; diff --git a/crates/dbconn/src/dbconn.rs b/crates/dbconn/src/dbconn.rs index d2af695..ffed680 100644 --- a/crates/dbconn/src/dbconn.rs +++ b/crates/dbconn/src/dbconn.rs @@ -12,6 +12,7 @@ pub mod pg { pub use tokio_postgres::Statement; } +use daqbuf_err as err; use err::anyhow; use err::thiserror; use err::Error; diff --git a/crates/dbconn/src/scan.rs b/crates/dbconn/src/scan.rs index d438baf..f827342 100644 --- a/crates/dbconn/src/scan.rs +++ b/crates/dbconn/src/scan.rs @@ -6,6 +6,7 @@ use async_channel::bounded; use async_channel::Receiver; use chrono::DateTime; use chrono::Utc; +use daqbuf_err as err; use err::Error; use futures_util::FutureExt; use futures_util::Stream; diff --git a/crates/dbconn/src/search.rs b/crates/dbconn/src/search.rs index 3092b16..5fd3523 100644 --- a/crates/dbconn/src/search.rs +++ b/crates/dbconn/src/search.rs @@ -1,6 +1,7 @@ use crate::create_connection; use crate::worker::PgQueue; use crate::ErrConv; +use daqbuf_err as err; use err::Error; use netpod::log::*; use netpod::ChannelArchiver; diff --git a/crates/dbconn/src/worker.rs b/crates/dbconn/src/worker.rs index 510867e..043398f 100644 --- a/crates/dbconn/src/worker.rs +++ b/crates/dbconn/src/worker.rs @@ -2,6 +2,7 @@ use crate::create_connection; use async_channel::Receiver; use async_channel::RecvError; use async_channel::Sender; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use netpod::log::*; diff --git a/crates/disk/Cargo.toml b/crates/disk/Cargo.toml index 70797db..4fcc0f4 100644 --- a/crates/disk/Cargo.toml +++ b/crates/disk/Cargo.toml @@ -30,7 +30,7 @@ num-traits = "0.2.14" num-derive = "0.4.0" url = "2.5.0" tiny-keccak = { version = "2.0", features = ["sha3"] } -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } taskrun = { path = "../taskrun" } netpod = { path = "../netpod" } query = { path = "../query" } diff --git a/crates/disk/src/aggtest.rs b/crates/disk/src/aggtest.rs index 96ccece..5e5bf4d 100644 --- a/crates/disk/src/aggtest.rs +++ b/crates/disk/src/aggtest.rs @@ -2,6 +2,7 @@ use crate::eventchunker::EventChunkerConf; use crate::eventchunkermultifile::EventChunkerMultifile; use crate::AggQuerySingleChannel; use crate::SfDbChConf; +use daqbuf_err as err; use err::Error; use netpod::range::evrange::NanoRange; use netpod::test_data_base_path_databuffer; diff --git a/crates/disk/src/binnedstream.rs b/crates/disk/src/binnedstream.rs index e4a59dd..ddc3950 100644 --- a/crates/disk/src/binnedstream.rs +++ b/crates/disk/src/binnedstream.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::Error; use futures_util::Stream; use futures_util::StreamExt; diff --git a/crates/disk/src/channelconfig.rs b/crates/disk/src/channelconfig.rs index 856a962..0b6f09a 100644 --- a/crates/disk/src/channelconfig.rs +++ b/crates/disk/src/channelconfig.rs @@ -1,4 +1,5 @@ use crate::SfDbChConf; +use daqbuf_err as err; use err::*; #[allow(unused)] use netpod::log::*; diff --git a/crates/disk/src/dataopen.rs b/crates/disk/src/dataopen.rs index 4dc3e3c..abe6648 100644 --- a/crates/disk/src/dataopen.rs +++ b/crates/disk/src/dataopen.rs @@ -1,5 +1,6 @@ use super::paths; use bytes::BytesMut; +use daqbuf_err as err; use err::ErrStr; use err::Error; use futures_util::StreamExt; diff --git a/crates/disk/src/decode.rs b/crates/disk/src/decode.rs index 4be8cf8..8926166 100644 --- a/crates/disk/src/decode.rs +++ b/crates/disk/src/decode.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::Error; use futures_util::Stream; use futures_util::StreamExt; diff --git a/crates/disk/src/disk.rs b/crates/disk/src/disk.rs index a872f6b..e412685 100644 --- a/crates/disk/src/disk.rs +++ b/crates/disk/src/disk.rs @@ -22,6 +22,7 @@ pub use parse; use async_channel::Receiver; use async_channel::Sender; use bytes::BytesMut; +use daqbuf_err as err; use err::Error; use futures_util::future::FusedFuture; use futures_util::FutureExt; diff --git a/crates/disk/src/eventchunker.rs b/crates/disk/src/eventchunker.rs index 39c032b..020241c 100644 --- a/crates/disk/src/eventchunker.rs +++ b/crates/disk/src/eventchunker.rs @@ -1,5 +1,6 @@ use bytes::Buf; use bytes::BytesMut; +use daqbuf_err as err; use err::thiserror; use err::Error; use err::ThisError; diff --git a/crates/disk/src/eventchunkermultifile.rs b/crates/disk/src/eventchunkermultifile.rs index 764c5e3..52b5148 100644 --- a/crates/disk/src/eventchunkermultifile.rs +++ b/crates/disk/src/eventchunkermultifile.rs @@ -3,6 +3,7 @@ use crate::dataopen::open_files; use crate::dataopen::OpenedFileSet; use crate::eventchunker::EventChunker; use crate::eventchunker::EventChunkerConf; +use daqbuf_err as err; use err::Error; use futures_util::Stream; use futures_util::StreamExt; diff --git a/crates/disk/src/gen.rs b/crates/disk/src/gen.rs index 00f2e41..c0c9515 100644 --- a/crates/disk/src/gen.rs +++ b/crates/disk/src/gen.rs @@ -3,6 +3,7 @@ use crate::SfDbChConf; use bitshuffle::bitshuffle_compress; use bytes::BufMut; use bytes::BytesMut; +use daqbuf_err as err; use err::Error; use netpod::log::*; use netpod::timeunits::*; diff --git a/crates/disk/src/index.rs b/crates/disk/src/index.rs index 77f43d3..aa892ea 100644 --- a/crates/disk/src/index.rs +++ b/crates/disk/src/index.rs @@ -1,4 +1,5 @@ use arrayref::array_ref; +use daqbuf_err as err; use err::Error; use netpod::log::*; use netpod::range::evrange::NanoRange; diff --git a/crates/disk/src/paths.rs b/crates/disk/src/paths.rs index c70f206..5e963f3 100644 --- a/crates/disk/src/paths.rs +++ b/crates/disk/src/paths.rs @@ -1,4 +1,5 @@ use crate::SfDbChConf; +use daqbuf_err as err; use err::Error; use futures_util::StreamExt; use netpod::timeunits::MS; diff --git a/crates/disk/src/raw/conn.rs b/crates/disk/src/raw/conn.rs index dcef738..5061c7b 100644 --- a/crates/disk/src/raw/conn.rs +++ b/crates/disk/src/raw/conn.rs @@ -2,6 +2,7 @@ use crate::eventchunker::EventChunkerConf; use crate::eventchunkermultifile::EventChunkerMultifile; use crate::raw::generated::EventBlobsGeneratorI32Test00; use crate::raw::generated::EventBlobsGeneratorI32Test01; +use daqbuf_err as err; use err::Error; use futures_util::stream; use futures_util::Stream; diff --git a/crates/disk/src/read3.rs b/crates/disk/src/read3.rs index 0bb7bb8..ce60c70 100644 --- a/crates/disk/src/read3.rs +++ b/crates/disk/src/read3.rs @@ -1,4 +1,5 @@ use bytes::BytesMut; +use daqbuf_err as err; use err::Error; use netpod::log::*; use std::os::unix::prelude::RawFd; diff --git a/crates/disk/src/read4.rs b/crates/disk/src/read4.rs index 485cae9..bde965a 100644 --- a/crates/disk/src/read4.rs +++ b/crates/disk/src/read4.rs @@ -1,4 +1,5 @@ use bytes::BytesMut; +use daqbuf_err as err; use err::Error; use netpod::log::*; use std::os::unix::prelude::RawFd; diff --git a/crates/dq/Cargo.toml b/crates/dq/Cargo.toml index 09594bb..58c8ff3 100644 --- a/crates/dq/Cargo.toml +++ b/crates/dq/Cargo.toml @@ -8,12 +8,12 @@ edition = "2021" path = "src/dq.rs" [dependencies] -tokio = { version = "1.21.1", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] } +tokio = { version = "1.41.1", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] } futures-util = "0.3.14" clap = { version = "4.0", features = ["derive", "cargo"] } chrono = "0.4.19" -bytes = "1.0.1" -err = { path = "../err" } +bytes = "1.7" +daqbuf-err = { path = "../../../daqbuf-err" } taskrun = { path = "../taskrun" } netpod = { path = "../netpod" } parse = { path = "../parse" } diff --git a/crates/dq/src/bin/daq-convert.rs b/crates/dq/src/bin/daq-convert.rs index f008b56..4e726ac 100644 --- a/crates/dq/src/bin/daq-convert.rs +++ b/crates/dq/src/bin/daq-convert.rs @@ -1,4 +1,5 @@ use clap::{ArgAction, Parser}; +use daqbuf_err as err; use err::Error; use netpod::timeunits::*; use std::path::PathBuf; diff --git a/crates/dq/src/bin/dq.rs b/crates/dq/src/bin/dq.rs index a6bf664..76449e3 100644 --- a/crates/dq/src/bin/dq.rs +++ b/crates/dq/src/bin/dq.rs @@ -1,5 +1,6 @@ use clap::ArgAction; use clap::Parser; +use daqbuf_err as err; use disk::eventchunker::EventChunker; use disk::eventchunker::EventChunkerConf; use err::Error; diff --git a/crates/err/Cargo.toml b/crates/err/Cargo.toml deleted file mode 100644 index 0c86c78..0000000 --- a/crates/err/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "err" -version = "0.0.5" -authors = ["Dominik Werder "] -edition = "2021" - -[lib] -doctest = false - -[dependencies] -backtrace = "0.3.68" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -serde_cbor = "0.11.2" -rmp-serde = "1.1.1" -async-channel = "1.9.0" -async_channel_2 = { package = "async-channel", version = "2.0.0" } -chrono = { version = "0.4.26", features = ["serde"] } -url = "2.4.0" -regex = "1.9.1" -http = "1.0.0" -#hyper = "1.0.1" -thiserror = "=0.0.1" -anyhow = "1.0" -#tokio = "1" - -[patch.crates-io] -thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" } diff --git a/crates/err/src/lib.rs b/crates/err/src/lib.rs deleted file mode 100644 index 2c1ff36..0000000 --- a/crates/err/src/lib.rs +++ /dev/null @@ -1,610 +0,0 @@ -//! Error handling and reporting. - -#[macro_export] -macro_rules! err_dbg_dis { - ($tt:ty, $nn:expr) => { - impl ::core::fmt::Display for $tt { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - write!(fmt, "{}::{:?}", $nn, self) - } - } - }; -} - -pub use anyhow; -pub use thiserror; -pub use thiserror::Error as ThisError; -// pub use thiserror::UserErrorClass; -// pub use thiserror::UserErrorContent; - -pub mod bt { - pub use backtrace::Backtrace; -} - -use serde::Deserialize; -use serde::Serialize; -use std::array::TryFromSliceError; -use std::convert::Infallible; -use std::fmt; -use std::net::AddrParseError; -use std::num::ParseFloatError; -use std::num::ParseIntError; -use std::string::FromUtf8Error; -use std::sync::PoisonError; - -pub type Res2 = anyhow::Result; - -#[derive(Debug, ThisError)] -pub enum ErrA { - #[error("bad-A")] - Bad, -} - -#[derive(Debug, ThisError)] -pub enum ErrB { - #[error("worse-B")] - Worse, - #[error("FromArrA")] - ErrA(#[from] ErrA), -} - -fn f_a() -> Result { - Err(ErrA::Bad) -} - -fn f_b() -> Result { - if true { - let res = f_a()?; - Ok(res) - } else { - Err(ErrB::Worse) - } -} - -#[allow(unused)] -fn f_c() -> Result { - return Ok(f_b()?); -} - -#[test] -fn test_fc() { - assert!(f_c().is_err()); -} - -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub enum Reason { - InternalError, - BadRequest, - IoError, -} - -/// The common error type for this application. -#[derive(Clone, PartialEq, Serialize, Deserialize)] -pub struct Error { - msg: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - trace_str: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - public_msg: Option>, - #[serde(default, skip_serializing_if = "Option::is_none")] - reason: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - parent: Option>, -} - -impl Error { - pub fn with_msg_no_trace>(s: S) -> Self { - Self { - msg: s.into(), - trace_str: None, - public_msg: None, - reason: None, - parent: None, - } - } - - pub fn with_msg>(s: S) -> Self { - Self::with_msg_no_trace(s).add_backtrace() - } - - pub fn with_public_msg_no_trace>(s: S) -> Self { - let s = s.into(); - let ret = Self::with_msg_no_trace(&s); - let ret = ret.add_public_msg(s); - ret - } - - pub fn with_public_msg>(s: S) -> Self { - let s = s.into(); - let ret = Self::with_msg_no_trace(String::new()); - let ret = ret.add_backtrace(); - let ret = ret.add_public_msg(s); - ret - } - - pub fn from_string(e: E) -> Self - where - E: ToString, - { - Self::with_msg_no_trace(e.to_string()) - } - - pub fn add_backtrace(mut self) -> Self { - self.msg.extend(" (add_backtrace DISABLED)".chars()); - // ret.trace_str = Some(fmt_backtrace(&backtrace::Backtrace::new())); - self - } - - pub fn mark_bad_request(mut self) -> Self { - self.reason = Some(Reason::BadRequest); - self - } - - pub fn mark_io_error(mut self) -> Self { - self.reason = Some(Reason::IoError); - self - } - - pub fn add_public_msg(mut self, msg: impl Into) -> Self { - if self.public_msg.is_none() { - self.public_msg = Some(Vec::new()); - } - self.public_msg.as_mut().unwrap().push(msg.into()); - self - } - - pub fn msg(&self) -> &str { - &self.msg - } - - pub fn public_msg(&self) -> Option<&Vec> { - self.public_msg.as_ref() - } - - pub fn reason(&self) -> Option { - self.reason.clone() - } -} - -#[allow(unused)] -fn fmt_backtrace(trace: &backtrace::Backtrace) -> String { - if true { - return String::from("fmt_backtrace DISABLED"); - } - use std::io::Write; - let mut buf = Vec::new(); - let mut c1 = 0; - 'outer: for fr in trace.frames() { - for sy in fr.symbols() { - let is_ours = match sy.filename() { - None => false, - Some(s) => { - let s = s.to_str().unwrap(); - s.contains("/dev/daqbuffer/") || s.contains("/build/daqbuffer/") - } - }; - let name = match sy.name() { - Some(k) => k.to_string(), - _ => "[err]".into(), - }; - let filename = match sy.filename() { - Some(k) => match k.to_str() { - Some(k) => k, - _ => "[err]", - }, - _ => "[err]", - }; - let lineno = match sy.lineno() { - Some(k) => k, - _ => 0, - }; - if is_ours { - write!(&mut buf, "\n {name}\n {filename} {lineno}").unwrap(); - c1 += 1; - if c1 >= 10 { - break 'outer; - } - } - } - } - String::from_utf8(buf).unwrap() -} - -impl fmt::Debug for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let trace_str = if let Some(s) = &self.trace_str { - s.into() - } else { - String::new() - }; - write!(fmt, "msg: {}", self.msg)?; - if let Some(msgs) = self.public_msg() { - for (i, msg) in msgs.iter().enumerate() { - write!(fmt, "; pub({i}): {msg}")?; - } - } - if !trace_str.is_empty() { - write!(fmt, "\nTrace:\n{}", trace_str)?; - } - Ok(()) - } -} - -impl fmt::Display for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(self, fmt) - } -} - -impl std::error::Error for Error {} - -pub trait ErrConv { - fn err_conv(self) -> Result; -} - -impl ErrConv for Result -where - E: Into, -{ - fn err_conv(self) -> Result { - match self { - Ok(k) => Ok(k), - Err(e) => Err(e.into()), - } - } -} - -pub trait ErrStr { - fn errstr(self) -> Result; -} - -impl ErrStr for Result -where - E: ToString, -{ - fn errstr(self) -> Result { - match self { - Ok(k) => Ok(k), - Err(e) => Err(Error::with_msg_no_trace(e.to_string())), - } - } -} - -pub trait ToErr { - fn to_err(self) -> Error; -} - -impl From for Error { - fn from(k: T) -> Self { - k.to_err() - } -} - -impl From for Error { - fn from(k: PublicError) -> Self { - Self { - msg: String::new(), - trace_str: None, - public_msg: Some(k.msg.clone()), - reason: k.reason(), - parent: None, - } - } -} - -impl ToErr for Infallible { - fn to_err(self) -> Error { - Error::with_msg_no_trace(String::new()) - } -} - -impl From for Error { - fn from(k: String) -> Self { - Self::from_string(k) - } -} - -impl From<&str> for Error { - fn from(k: &str) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: std::io::Error) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: AddrParseError) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: serde_json::Error) -> Self { - Self::from_string(k) - } -} - -impl From> for Error { - fn from(k: async_channel::SendError) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: async_channel::RecvError) -> Self { - Self::from_string(k) - } -} - -impl From> for Error { - fn from(k: async_channel_2::SendError) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: async_channel_2::RecvError) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: chrono::format::ParseError) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: ParseIntError) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: ParseFloatError) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: FromUtf8Error) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: std::str::Utf8Error) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: serde_cbor::Error) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: std::fmt::Error) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: regex::Error) -> Self { - Self::from_string(k) - } -} - -impl From> for Error { - fn from(_: PoisonError) -> Self { - Self::from_string("PoisonError") - } -} - -impl From for Error { - fn from(k: url::ParseError) -> Self { - Self::from_string(format!("{:?}", k)) - } -} - -impl From for Error { - fn from(k: TryFromSliceError) -> Self { - Self::from_string(format!("{:?}", k)) - } -} - -impl From for Error { - fn from(k: rmp_serde::encode::Error) -> Self { - Self::from_string(format!("{:?}", k)) - } -} - -impl From for Error { - fn from(k: rmp_serde::decode::Error) -> Self { - Self::from_string(format!("{:?}", k)) - } -} - -impl From for Error { - fn from(k: anyhow::Error) -> Self { - Self::from_string(format!("{k}")) - } -} - -impl From for Error { - fn from(k: http::Error) -> Self { - Self::from_string(k) - } -} - -impl From for Error { - fn from(k: http::uri::InvalidUri) -> Self { - Self::from_string(k) - } -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct PublicError { - reason: Option, - msg: Vec, -} - -impl PublicError { - pub fn reason(&self) -> Option { - self.reason.clone() - } - - pub fn msg(&self) -> &Vec { - &self.msg - } -} - -impl From for PublicError { - fn from(value: String) -> Self { - Self { - reason: None, - msg: vec![value], - } - } -} - -impl From for PublicError { - fn from(k: Error) -> Self { - Self { - reason: k.reason(), - msg: k.public_msg().map(Clone::clone).unwrap_or(Vec::new()), - } - } -} - -impl From<&Error> for PublicError { - fn from(k: &Error) -> Self { - Self { - reason: k.reason(), - msg: vec![k.msg().into()], - } - } -} - -impl fmt::Display for PublicError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{:?}", self.msg) - } -} - -impl ToPublicError for Error { - fn to_public_error(&self) -> PublicError { - PublicError::from(self) - } -} - -pub fn todo() { - let bt = backtrace::Backtrace::new(); - eprintln!("TODO\n{bt:?}"); - todo!("TODO\n{bt:?}"); -} - -pub fn todoval() -> T { - let bt = backtrace::Backtrace::new(); - eprintln!("TODO\n{bt:?}"); - todo!("TODO todoval\n{bt:?}") -} - -pub trait ToPublicError: std::error::Error + Send { - fn to_public_error(&self) -> PublicError; -} - -#[cfg(test)] -mod test { - use super::*; - - #[derive(Debug, ThisError, Serialize, Deserialize)] - #[cstm(name = "SomeErrorEnumA")] - enum SomeErrorEnumA { - BadCase, - WithStringContent(String), - // #[error("bad: {0}")] - WithStringContentFmt(String), - } - - #[derive(Debug, ThisError, Serialize, Deserialize)] - #[cstm(name = "SomeErrorEnumB0")] - enum SomeErrorEnumB0 { - FromA(#[from] SomeErrorEnumA), - } - - #[derive(Debug, ThisError, Serialize, Deserialize)] - #[cstm(name = "SomeErrorEnumB1")] - enum SomeErrorEnumB1 { - FromA(#[from] SomeErrorEnumA), - #[error("caffe")] - Caffe(SomeErrorEnumA), - } - - fn failing_a_00() -> Result<(), SomeErrorEnumA> { - Err(SomeErrorEnumA::BadCase) - } - - fn failing_b0_00() -> Result<(), SomeErrorEnumB0> { - let ret = failing_a_00()?; - Ok(ret) - } - - fn failing_b1_00() -> Result<(), SomeErrorEnumB1> { - let ret = failing_a_00()?; - Ok(ret) - } - - #[test] - fn error_handle_a_00() { - assert_eq!(format!("{}", SomeErrorEnumA::BadCase), "SomeErrorEnumA::BadCase"); - } - - #[test] - fn error_handle_a_01() { - assert_eq!( - SomeErrorEnumA::WithStringContent(format!("inner")).to_string(), - "SomeErrorEnumA::WithStringContent" - ); - } - - #[test] - fn error_handle_a_02() { - assert_eq!( - SomeErrorEnumA::WithStringContentFmt(format!("inner failure \"quoted\"")).to_string(), - "bad: inner failure \"quoted\"" - ); - } - - #[test] - fn error_handle_b0_00() { - let e = failing_b0_00().unwrap_err(); - let s = e.to_string(); - assert_eq!(s, "SomeErrorEnumB0::FromA(SomeErrorEnumA::BadCase)"); - } - - #[test] - fn error_handle_b0_user_00() { - use thiserror::UserErrorClass; - use thiserror::UserErrorInfo; - let e = failing_b0_00().unwrap_err(); - let s = e.class(); - if let UserErrorClass::Unspecified = s { - () - } else { - panic!() - } - } - - #[test] - fn error_handle_b1_00() { - let e = failing_b1_00().unwrap_err(); - let s = e.to_string(); - assert_eq!(s, "SomeErrorEnumB1::FromA(SomeErrorEnumA::BadCase)"); - } -} diff --git a/crates/httpclient/Cargo.toml b/crates/httpclient/Cargo.toml index 5a8b70e..9ebf83f 100644 --- a/crates/httpclient/Cargo.toml +++ b/crates/httpclient/Cargo.toml @@ -19,7 +19,7 @@ hyper = { version = "1.0.1", features = ["http1", "http2", "client", "server"] } hyper-util = { version = "0.1.1", features = ["full"] } bytes = "1.5.0" async-channel = "1.9.0" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } netpod = { path = "../netpod" } parse = { path = "../parse" } streams = { path = "../streams" } diff --git a/crates/httpclient/src/httpclient.rs b/crates/httpclient/src/httpclient.rs index 4549ccd..421ba85 100644 --- a/crates/httpclient/src/httpclient.rs +++ b/crates/httpclient/src/httpclient.rs @@ -5,6 +5,7 @@ pub use hyper_util; use bytes::BufMut; use bytes::Bytes; use bytes::BytesMut; +use daqbuf_err as err; use futures_util::Stream; use futures_util::StreamExt; use http::header; diff --git a/crates/httpret/Cargo.toml b/crates/httpret/Cargo.toml index b183779..f93d0cb 100644 --- a/crates/httpret/Cargo.toml +++ b/crates/httpret/Cargo.toml @@ -28,7 +28,7 @@ rand = "0.8.5" ciborium = "0.2.1" flate2 = "1" brotli = "3.4.0" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } netpod = { path = "../netpod" } query = { path = "../query" } dbconn = { path = "../dbconn" } diff --git a/crates/httpret/src/api1.rs b/crates/httpret/src/api1.rs index d300c3d..a04f2cb 100644 --- a/crates/httpret/src/api1.rs +++ b/crates/httpret/src/api1.rs @@ -11,6 +11,7 @@ use crate::ServiceSharedResources; use bytes::BufMut; use bytes::Bytes; use bytes::BytesMut; +use daqbuf_err as err; use disk::merge::mergedblobsfromremotes::MergedBlobsFromRemotes; use futures_util::Stream; use futures_util::StreamExt; diff --git a/crates/httpret/src/api4/accounting.rs b/crates/httpret/src/api4/accounting.rs index ec37dbd..2ded292 100644 --- a/crates/httpret/src/api4/accounting.rs +++ b/crates/httpret/src/api4/accounting.rs @@ -3,6 +3,7 @@ use crate::err::Error; use crate::requests::accepts_json_or_all; use crate::ReqCtx; use crate::ServiceSharedResources; +use daqbuf_err as err; use dbconn::worker::PgQueue; use err::ToPublicError; use http::Method; diff --git a/crates/httpret/src/api4/binned.rs b/crates/httpret/src/api4/binned.rs index 021a0c9..a4831fb 100644 --- a/crates/httpret/src/api4/binned.rs +++ b/crates/httpret/src/api4/binned.rs @@ -5,6 +5,7 @@ use crate::requests::accepts_json_framed; use crate::requests::accepts_json_or_all; use crate::requests::accepts_octets; use crate::ServiceSharedResources; +use daqbuf_err as err; use dbconn::worker::PgQueue; use err::thiserror; use err::ThisError; @@ -55,7 +56,7 @@ pub enum Error { EventsCbor(#[from] streams::plaineventscbor::Error), EventsJson(#[from] streams::plaineventsjson::Error), ServerError, - BinnedStream(::err::Error), + BinnedStream(err::Error), TimebinnedJson(#[from] streams::timebinnedjson::Error), } diff --git a/crates/httpret/src/api4/databuffer_tools.rs b/crates/httpret/src/api4/databuffer_tools.rs index 83b6641..eae20f4 100644 --- a/crates/httpret/src/api4/databuffer_tools.rs +++ b/crates/httpret/src/api4/databuffer_tools.rs @@ -2,6 +2,7 @@ use crate::bodystream::response; use async_channel::Receiver; use async_channel::Sender; use bytes::Bytes; +use daqbuf_err as err; use err::thiserror; use err::PublicError; use err::ThisError; diff --git a/crates/httpret/src/api4/eventdata.rs b/crates/httpret/src/api4/eventdata.rs index b23834f..795af03 100644 --- a/crates/httpret/src/api4/eventdata.rs +++ b/crates/httpret/src/api4/eventdata.rs @@ -1,6 +1,7 @@ use crate::response; use crate::ReqCtx; use crate::ServiceSharedResources; +use daqbuf_err as err; use err::thiserror; use err::PublicError; use err::ThisError; diff --git a/crates/httpret/src/api4/events.rs b/crates/httpret/src/api4/events.rs index c98761c..be2616a 100644 --- a/crates/httpret/src/api4/events.rs +++ b/crates/httpret/src/api4/events.rs @@ -6,6 +6,7 @@ use crate::response; use crate::ServiceSharedResources; use bytes::Bytes; use bytes::BytesMut; +use daqbuf_err as err; use dbconn::worker::PgQueue; use err::thiserror; use err::ThisError; diff --git a/crates/httpret/src/bodystream.rs b/crates/httpret/src/bodystream.rs index 7609ad0..728a628 100644 --- a/crates/httpret/src/bodystream.rs +++ b/crates/httpret/src/bodystream.rs @@ -1,4 +1,5 @@ use crate::err::Error; +use daqbuf_err as err; use err::ToPublicError; use http::Response; use http::StatusCode; @@ -26,7 +27,7 @@ impl ToPublicResponse for Error { } } -impl ToPublicResponse for ::err::Error { +impl ToPublicResponse for daqbuf_err::Error { fn to_public_response(&self) -> StreamResponse { use err::Reason; let e = self.to_public_error(); diff --git a/crates/httpret/src/channelconfig.rs b/crates/httpret/src/channelconfig.rs index 4954091..ae64e05 100644 --- a/crates/httpret/src/channelconfig.rs +++ b/crates/httpret/src/channelconfig.rs @@ -48,7 +48,7 @@ pub enum Error { Http(crate::Error), HttpCrate(http::Error), // TODO create dedicated error type for query parsing - BadQuery(err::Error), + BadQuery(daqbuf_err::Error), MissingBackend, MissingScalarType, MissingShape, @@ -56,12 +56,12 @@ pub enum Error { MissingEdge, MissingTimerange, Uri(netpod::UriError), - ChannelConfigQuery(err::Error), + ChannelConfigQuery(daqbuf_err::Error), ExpectScyllaBackend, Pg(dbconn::pg::Error), Scylla(String), Join, - OtherErr(err::Error), + OtherErr(daqbuf_err::Error), PgWorker(dbconn::worker::Error), Async(netpod::AsyncChannelError), ChannelConfig(dbconn::channelconfig::Error), @@ -102,7 +102,7 @@ impl fmt::Display for Error { } } -fn other_err_error(e: err::Error) -> Error { +fn other_err_error(e: daqbuf_err::Error) -> Error { Error::OtherErr(e) } @@ -446,7 +446,7 @@ pub struct ChannelsWithTypeQuery { } impl FromUrl for ChannelsWithTypeQuery { - type Error = err::Error; + type Error = daqbuf_err::Error; fn from_url(url: &Url) -> Result { let pairs = get_url_query_pairs(url); @@ -456,12 +456,12 @@ impl FromUrl for ChannelsWithTypeQuery { fn from_pairs(pairs: &BTreeMap) -> Result { let s = pairs .get("scalar_type") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing scalar_type"))?; + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing scalar_type"))?; //let scalar_type = ScalarType::from_bsread_str(s)?; let scalar_type: ScalarType = serde_json::from_str(&format!("\"{s}\""))?; let s = pairs .get("shape") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing shape"))?; + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing shape"))?; let shape = Shape::from_dims_str(s)?; Ok(Self { scalar_type, shape }) } @@ -484,29 +484,29 @@ fn bool_false(x: &bool) -> bool { } impl FromUrl for ScyllaChannelEventSeriesIdQuery { - type Error = err::Error; + type Error = daqbuf_err::Error; - fn from_url(url: &Url) -> Result { + fn from_url(url: &Url) -> Result { let pairs = get_url_query_pairs(url); Self::from_pairs(&pairs) } - fn from_pairs(pairs: &BTreeMap) -> Result { + fn from_pairs(pairs: &BTreeMap) -> Result { let backend = pairs .get("backend") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing backend"))? + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing backend"))? .into(); let name = pairs .get("channelName") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing channelName"))? + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing channelName"))? .into(); let s = pairs .get("scalarType") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing scalarType"))?; + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing scalarType"))?; let scalar_type: ScalarType = serde_json::from_str(&format!("\"{s}\""))?; let s = pairs .get("shape") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing shape"))?; + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing shape"))?; let shape = Shape::from_dims_str(s)?; let do_create = pairs.get("doCreate").map_or("false", |x| x.as_str()) == "true"; Ok(Self { @@ -535,25 +535,25 @@ pub struct ScyllaChannelsActiveQuery { } impl FromUrl for ScyllaChannelsActiveQuery { - type Error = err::Error; + type Error = daqbuf_err::Error; - fn from_url(url: &Url) -> Result { + fn from_url(url: &Url) -> Result { let pairs = get_url_query_pairs(url); Self::from_pairs(&pairs) } - fn from_pairs(pairs: &BTreeMap) -> Result { + fn from_pairs(pairs: &BTreeMap) -> Result { let s = pairs .get("tsedge") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing tsedge"))?; + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing tsedge"))?; let tsedge: u64 = s.parse()?; let s = pairs .get("shapeKind") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing shapeKind"))?; + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing shapeKind"))?; let shape_kind: u32 = s.parse()?; let s = pairs .get("scalarType") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing scalarType"))?; + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing scalarType"))?; let scalar_type: ScalarType = serde_json::from_str(&format!("\"{s}\""))?; info!("parsed scalar type inp: {s:?} val: {scalar_type:?}"); Ok(Self { @@ -643,7 +643,7 @@ pub struct IocForChannelQuery { } impl FromUrl for IocForChannelQuery { - type Error = err::Error; + type Error = daqbuf_err::Error; fn from_url(url: &Url) -> Result { let pairs = get_url_query_pairs(url); @@ -653,11 +653,11 @@ impl FromUrl for IocForChannelQuery { fn from_pairs(pairs: &BTreeMap) -> Result { let backend = pairs .get("backend") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing backend"))? + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing backend"))? .into(); let name = pairs .get("channelName") - .ok_or_else(|| err::Error::with_public_msg_no_trace("missing channelName"))? + .ok_or_else(|| daqbuf_err::Error::with_public_msg_no_trace("missing channelName"))? .into(); Ok(Self { backend, name }) } diff --git a/crates/httpret/src/err.rs b/crates/httpret/src/err.rs index 537ab33..840f1c1 100644 --- a/crates/httpret/src/err.rs +++ b/crates/httpret/src/err.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::ToPublicError; use serde::Deserialize; use serde::Serialize; @@ -28,7 +29,7 @@ impl Error { self.0.msg() } - pub fn reason(&self) -> Option<::err::Reason> { + pub fn reason(&self) -> Option { self.0.reason() } @@ -84,7 +85,7 @@ where T: ToString, { fn from(x: T) -> Self { - Self(::err::Error::from_string(x)) + Self(err::Error::from_string(x)) } } diff --git a/crates/httpret/src/httpret.rs b/crates/httpret/src/httpret.rs index fc0c53e..843a0ab 100644 --- a/crates/httpret/src/httpret.rs +++ b/crates/httpret/src/httpret.rs @@ -16,8 +16,9 @@ pub mod settings; use crate::bodystream::response; use crate::err::Error; -use ::err::thiserror; -use ::err::ThisError; +use daqbuf_err; +use daqbuf_err::thiserror; +use daqbuf_err::ThisError; use dbconn::worker::PgQueue; use dbconn::worker::PgWorker; use futures_util::Future; @@ -63,7 +64,7 @@ use tracing::Instrument; #[derive(Debug, ThisError, Serialize, Deserialize)] #[cstm(name = "Retrieval")] pub enum RetrievalError { - Error(#[from] ::err::Error), + Error(#[from] daqbuf_err::Error), Error2(#[from] crate::err::Error), TextError(String), #[serde(skip)] @@ -99,9 +100,9 @@ where } } -impl ::err::ToErr for RetrievalError { - fn to_err(self) -> ::err::Error { - ::err::Error::with_msg_no_trace(self.to_string()) +impl daqbuf_err::ToErr for RetrievalError { + fn to_err(self) -> daqbuf_err::Error { + daqbuf_err::Error::with_msg_no_trace(self.to_string()) } } diff --git a/crates/httpret/src/proxy/api4.rs b/crates/httpret/src/proxy/api4.rs index cb64af0..928c939 100644 --- a/crates/httpret/src/proxy/api4.rs +++ b/crates/httpret/src/proxy/api4.rs @@ -233,14 +233,14 @@ impl StatusNodesRecursive { for (tag, sr) in all { match sr { Ok(sr) => { - let s: Result = serde_json::from_value(sr.val).map_err(err::Error::from); + let s: Result = serde_json::from_value(sr.val).map_err(daqbuf_err::Error::from); let sub = NodeStatusSub { url: tag.0, status: s }; subs.push_back(sub); } Err(e) => { let sub = NodeStatusSub { url: tag.0, - status: Err(err::Error::from(e)), + status: Err(daqbuf_err::Error::from(e)), }; subs.push_back(sub); } diff --git a/crates/httpret/src/pulsemap.rs b/crates/httpret/src/pulsemap.rs index d8e94ed..1d0f9a6 100644 --- a/crates/httpret/src/pulsemap.rs +++ b/crates/httpret/src/pulsemap.rs @@ -889,24 +889,24 @@ struct LocalMap { } pub trait ErrConv { - fn err_conv(self) -> Result; + fn err_conv(self) -> Result; } impl ErrConv for Result { - fn err_conv(self) -> Result { - self.map_err(|e| err::Error::with_msg_no_trace(format!("{e:?}"))) + fn err_conv(self) -> Result { + self.map_err(|e| daqbuf_err::Error::with_msg_no_trace(format!("{e:?}"))) } } impl ErrConv for Result { - fn err_conv(self) -> Result { - self.map_err(|e| err::Error::with_msg_no_trace(format!("{e:?}"))) + fn err_conv(self) -> Result { + self.map_err(|e| daqbuf_err::Error::with_msg_no_trace(format!("{e:?}"))) } } impl ErrConv for Result { - fn err_conv(self) -> Result { - self.map_err(|e| err::Error::with_msg_no_trace(format!("{e:?}"))) + fn err_conv(self) -> Result { + self.map_err(|e| daqbuf_err::Error::with_msg_no_trace(format!("{e:?}"))) } } diff --git a/crates/items_0/Cargo.toml b/crates/items_0/Cargo.toml index 4e7e154..1533b40 100644 --- a/crates/items_0/Cargo.toml +++ b/crates/items_0/Cargo.toml @@ -17,4 +17,4 @@ bytes = "1.2.1" futures-util = "0.3.24" chrono = { version = "0.4.19", features = ["serde"] } netpod = { path = "../netpod" } -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } diff --git a/crates/items_0/src/collect_s.rs b/crates/items_0/src/collect_s.rs index fcf1d83..f57cee6 100644 --- a/crates/items_0/src/collect_s.rs +++ b/crates/items_0/src/collect_s.rs @@ -5,6 +5,7 @@ use crate::AsAnyRef; use crate::Events; use crate::TypeName; use crate::WithLen; +use daqbuf_err as err; use err::Error; use netpod::log::*; use netpod::range::evrange::SeriesRange; diff --git a/crates/items_0/src/items_0.rs b/crates/items_0/src/items_0.rs index 6943dbf..10877a7 100644 --- a/crates/items_0/src/items_0.rs +++ b/crates/items_0/src/items_0.rs @@ -19,6 +19,7 @@ pub use futures_util; use collect_s::CollectableDyn; use container::ByteEstimate; +use daqbuf_err as err; use std::any::Any; use std::collections::VecDeque; use std::fmt; diff --git a/crates/items_0/src/scalar_ops.rs b/crates/items_0/src/scalar_ops.rs index 1886577..2e739fa 100644 --- a/crates/items_0/src/scalar_ops.rs +++ b/crates/items_0/src/scalar_ops.rs @@ -1,5 +1,6 @@ use crate::container::ByteEstimate; use crate::subfr::SubFrId; +use daqbuf_err as err; use netpod::EnumVariant; use netpod::StringFix; use serde::Serialize; diff --git a/crates/items_0/src/streamitem.rs b/crates/items_0/src/streamitem.rs index ef18714..00b28de 100644 --- a/crates/items_0/src/streamitem.rs +++ b/crates/items_0/src/streamitem.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use netpod::log::Level; use netpod::DiskStats; use netpod::EventDataReadStats; diff --git a/crates/items_0/src/transform.rs b/crates/items_0/src/transform.rs index e5580ea..1908ea2 100644 --- a/crates/items_0/src/transform.rs +++ b/crates/items_0/src/transform.rs @@ -4,6 +4,7 @@ use crate::streamitem::RangeCompletableItem; use crate::streamitem::Sitemty; use crate::streamitem::StreamItem; use crate::Events; +use daqbuf_err as err; use err::Error; use futures_util::stream; use futures_util::Future; diff --git a/crates/items_2/Cargo.toml b/crates/items_2/Cargo.toml index c2dbf4e..f71723e 100644 --- a/crates/items_2/Cargo.toml +++ b/crates/items_2/Cargo.toml @@ -23,7 +23,7 @@ crc32fast = "1.3.2" futures-util = "0.3.24" humantime-serde = "1.1.1" thiserror = "0.0.1" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } items_0 = { path = "../items_0" } items_proc = { path = "../items_proc" } netpod = { path = "../netpod" } diff --git a/crates/items_2/src/binning/container_bins.rs b/crates/items_2/src/binning/container_bins.rs index 31059eb..d2ed4d3 100644 --- a/crates/items_2/src/binning/container_bins.rs +++ b/crates/items_2/src/binning/container_bins.rs @@ -5,6 +5,7 @@ use super::___; use crate::ts_offs_from_abs; use crate::ts_offs_from_abs_with_anchor; use core::fmt; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use items_0::collect_s::CollectableDyn; diff --git a/crates/items_2/src/binning/container_events.rs b/crates/items_2/src/binning/container_events.rs index 5a08ff8..902a3e5 100644 --- a/crates/items_2/src/binning/container_events.rs +++ b/crates/items_2/src/binning/container_events.rs @@ -3,6 +3,7 @@ use super::aggregator::AggregatorNumeric; use super::aggregator::AggregatorTimeWeight; use super::timeweight::timeweight_events_dyn::BinnedEventsTimeweightDynbox; use core::fmt; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use items_0::timebin::BinningggContainerEventsDyn; diff --git a/crates/items_2/src/binning/test/events00.rs b/crates/items_2/src/binning/test/events00.rs index ba19c03..80096ca 100644 --- a/crates/items_2/src/binning/test/events00.rs +++ b/crates/items_2/src/binning/test/events00.rs @@ -1,6 +1,7 @@ use crate::binning::container_bins::ContainerBins; use crate::binning::container_events::ContainerEvents; use crate::binning::timeweight::timeweight_events::BinnedEventsTimeweight; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use netpod::log::*; diff --git a/crates/items_2/src/binning/timeweight/timeweight_events.rs b/crates/items_2/src/binning/timeweight/timeweight_events.rs index 6553fa9..c68008d 100644 --- a/crates/items_2/src/binning/timeweight/timeweight_events.rs +++ b/crates/items_2/src/binning/timeweight/timeweight_events.rs @@ -5,6 +5,7 @@ use crate::binning::container_events::ContainerEvents; use crate::binning::container_events::ContainerEventsTakeUpTo; use crate::binning::container_events::EventSingle; use core::fmt; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use netpod::log::*; diff --git a/crates/items_2/src/binning/timeweight/timeweight_events_dyn.rs b/crates/items_2/src/binning/timeweight/timeweight_events_dyn.rs index a242639..b5f71bc 100644 --- a/crates/items_2/src/binning/timeweight/timeweight_events_dyn.rs +++ b/crates/items_2/src/binning/timeweight/timeweight_events_dyn.rs @@ -2,6 +2,7 @@ use super::timeweight_events::BinnedEventsTimeweight; use crate::binning::container_events::ContainerEvents; use crate::binning::container_events::EventValueType; use crate::channelevents::ChannelEvents; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use futures_util::Stream; @@ -183,11 +184,11 @@ impl BinnedEventsTimeweightStream { } } Ok(None) => Continue(()), - Err(e) => Break(Ready(Some(Err(::err::Error::from_string(e))))), + Err(e) => Break(Ready(Some(Err(err::Error::from_string(e))))), } // Continue(()) } - Err(e) => Break(Ready(Some(Err(::err::Error::from_string(e))))), + Err(e) => Break(Ready(Some(Err(err::Error::from_string(e))))), }, ChannelEvents::Status(_) => { // TODO use the status @@ -218,13 +219,13 @@ impl BinnedEventsTimeweightStream { if self.range_complete { self.binned_events .input_done_range_final() - .map_err(::err::Error::from_string)?; + .map_err(err::Error::from_string)?; } else { self.binned_events .input_done_range_open() - .map_err(::err::Error::from_string)?; + .map_err(err::Error::from_string)?; } - match self.binned_events.output().map_err(::err::Error::from_string)? { + match self.binned_events.output().map_err(err::Error::from_string)? { Some(x) => { trace_emit!("seeing ready bins {:?}", x); Ready(Some(Ok(DataItem(Data(x))))) diff --git a/crates/items_2/src/binsdim0.rs b/crates/items_2/src/binsdim0.rs index 8cc4ee1..4b3d969 100644 --- a/crates/items_2/src/binsdim0.rs +++ b/crates/items_2/src/binsdim0.rs @@ -1,6 +1,7 @@ use crate::ts_offs_from_abs; use crate::ts_offs_from_abs_with_anchor; use crate::IsoDateTime; +use daqbuf_err as err; use err::Error; use items_0::collect_s::CollectableDyn; use items_0::collect_s::CollectableType; diff --git a/crates/items_2/src/binsxbindim0.rs b/crates/items_2/src/binsxbindim0.rs index 136768f..326f69b 100644 --- a/crates/items_2/src/binsxbindim0.rs +++ b/crates/items_2/src/binsxbindim0.rs @@ -1,6 +1,7 @@ use crate::ts_offs_from_abs; use crate::ts_offs_from_abs_with_anchor; use crate::IsoDateTime; +use daqbuf_err as err; use err::Error; use items_0::collect_s::CollectableDyn; use items_0::collect_s::CollectableType; diff --git a/crates/items_2/src/channelevents.rs b/crates/items_2/src/channelevents.rs index 457110c..3ce2736 100644 --- a/crates/items_2/src/channelevents.rs +++ b/crates/items_2/src/channelevents.rs @@ -1,6 +1,7 @@ use crate::framable::FrameType; use crate::merger::Mergeable; use crate::Events; +use daqbuf_err as err; use items_0::collect_s::CollectableDyn; use items_0::collect_s::CollectedDyn; use items_0::collect_s::CollectorDyn; diff --git a/crates/items_2/src/empty.rs b/crates/items_2/src/empty.rs index 0fa0840..dc2e6b2 100644 --- a/crates/items_2/src/empty.rs +++ b/crates/items_2/src/empty.rs @@ -1,6 +1,7 @@ use crate::eventsdim0::EventsDim0; use crate::eventsdim1::EventsDim1; use crate::Error; +use daqbuf_err as err; use items_0::Empty; use items_0::Events; use netpod::log::*; diff --git a/crates/items_2/src/eventfull.rs b/crates/items_2/src/eventfull.rs index e9bcbf6..b686933 100644 --- a/crates/items_2/src/eventfull.rs +++ b/crates/items_2/src/eventfull.rs @@ -1,6 +1,7 @@ use crate::framable::FrameType; use crate::merger::Mergeable; use bytes::BytesMut; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use items_0::container::ByteEstimate; diff --git a/crates/items_2/src/eventsdim0.rs b/crates/items_2/src/eventsdim0.rs index d87f6a3..f9a10c8 100644 --- a/crates/items_2/src/eventsdim0.rs +++ b/crates/items_2/src/eventsdim0.rs @@ -1,4 +1,5 @@ use crate::IsoDateTime; +use daqbuf_err as err; use err::Error; use items_0::collect_s::CollectableDyn; use items_0::collect_s::CollectedDyn; diff --git a/crates/items_2/src/eventsdim0enum.rs b/crates/items_2/src/eventsdim0enum.rs index babe914..50f7da2 100644 --- a/crates/items_2/src/eventsdim0enum.rs +++ b/crates/items_2/src/eventsdim0enum.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::Error; use items_0::collect_s::CollectableDyn; use items_0::collect_s::CollectedDyn; diff --git a/crates/items_2/src/eventsdim1.rs b/crates/items_2/src/eventsdim1.rs index 4158cc1..9c5a9b5 100644 --- a/crates/items_2/src/eventsdim1.rs +++ b/crates/items_2/src/eventsdim1.rs @@ -1,6 +1,7 @@ use crate::binsdim0::BinsDim0; use crate::eventsxbindim0::EventsXbinDim0; use crate::IsoDateTime; +use daqbuf_err as err; use err::Error; use items_0::collect_s::CollectableDyn; use items_0::collect_s::CollectableType; diff --git a/crates/items_2/src/eventsxbindim0.rs b/crates/items_2/src/eventsxbindim0.rs index b79ad77..c2256ea 100644 --- a/crates/items_2/src/eventsxbindim0.rs +++ b/crates/items_2/src/eventsxbindim0.rs @@ -1,5 +1,6 @@ use crate::binsxbindim0::BinsXbinDim0; use crate::IsoDateTime; +use daqbuf_err as err; use err::Error; use items_0::collect_s::CollectableDyn; use items_0::collect_s::CollectableType; diff --git a/crates/items_2/src/framable.rs b/crates/items_2/src/framable.rs index d34d407..33629c4 100644 --- a/crates/items_2/src/framable.rs +++ b/crates/items_2/src/framable.rs @@ -4,6 +4,7 @@ use crate::frame::make_log_frame; use crate::frame::make_range_complete_frame; use crate::frame::make_stats_frame; use bytes::BytesMut; +use daqbuf_err as err; use items_0::framable::FrameTypeInnerDyn; use items_0::framable::FrameTypeInnerStatic; use items_0::streamitem::LogItem; diff --git a/crates/items_2/src/frame.rs b/crates/items_2/src/frame.rs index 407dc7f..3e736b2 100644 --- a/crates/items_2/src/frame.rs +++ b/crates/items_2/src/frame.rs @@ -13,6 +13,7 @@ use bincode::config::WithOtherTrailing; use bincode::DefaultOptions; use bytes::BufMut; use bytes::BytesMut; +use daqbuf_err as err; use items_0::bincode; use items_0::streamitem::LogItem; use items_0::streamitem::StatsItem; diff --git a/crates/items_2/src/items_2.rs b/crates/items_2/src/items_2.rs index b407c79..300d198 100644 --- a/crates/items_2/src/items_2.rs +++ b/crates/items_2/src/items_2.rs @@ -21,6 +21,7 @@ pub mod testgen; pub mod transform; use channelevents::ChannelEvents; +use daqbuf_err as err; use futures_util::Stream; use items_0::isodate::IsoDateTime; use items_0::streamitem::Sitemty; diff --git a/crates/netpod/Cargo.toml b/crates/netpod/Cargo.toml index e15698c..e92f10c 100644 --- a/crates/netpod/Cargo.toml +++ b/crates/netpod/Cargo.toml @@ -22,7 +22,7 @@ num-traits = "0.2.16" hex = "0.4.3" rand = "0.8.5" thiserror = "0.0.1" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } [patch.crates-io] thiserror = { git = "https://github.com/dominikwerder/thiserror.git", branch = "cstm" } diff --git a/crates/netpod/src/channelstatus.rs b/crates/netpod/src/channelstatus.rs index c4697b7..dfbe362 100644 --- a/crates/netpod/src/channelstatus.rs +++ b/crates/netpod/src/channelstatus.rs @@ -1,3 +1,5 @@ +use daqbuf_err as err; + #[derive(Debug, Clone)] pub enum ChannelStatusClosedReason { ShutdownCommand, diff --git a/crates/netpod/src/netpod.rs b/crates/netpod/src/netpod.rs index df61d30..0e50943 100644 --- a/crates/netpod/src/netpod.rs +++ b/crates/netpod/src/netpod.rs @@ -60,6 +60,8 @@ pub mod log_ { pub use tracing::{self, event, span, Level}; } +use daqbuf_err as err; + use bytes::Bytes; use chrono::DateTime; use chrono::TimeZone; @@ -4103,7 +4105,7 @@ pub struct StatusBoardEntry { // #[serde(skip_serializing_if = "is_false")] done: bool, // #[serde(skip_serializing_if = "Vec::is_empty")] - errors: Vec<::err::Error>, + errors: Vec, // TODO make this a better Stats container and remove pub access. // #[serde(default, skip_serializing_if = "CmpZero::is_zero")] error_count: usize, @@ -4170,7 +4172,7 @@ pub struct StatusBoardEntryUser { // #[serde(default, skip_serializing_if = "CmpZero::is_zero")] channel_not_found: usize, #[serde(skip_serializing_if = "Vec::is_empty")] - errors: Vec<::err::PublicError>, + errors: Vec, } impl StatusBoardEntryUser { @@ -4257,7 +4259,7 @@ impl StatusBoard { } } - pub fn add_error(&mut self, status_id: &str, err: ::err::Error) { + pub fn add_error(&mut self, status_id: &str, err: err::Error) { match self.entries.get_mut(status_id) { Some(e) => { e.ts_updated = SystemTime::now(); diff --git a/crates/netpod/src/query.rs b/crates/netpod/src/query.rs index c1114d5..a8b2e47 100644 --- a/crates/netpod/src/query.rs +++ b/crates/netpod/src/query.rs @@ -2,6 +2,8 @@ pub mod api1; pub mod datetime; pub mod prebinned; +use daqbuf_err as err; + use crate::get_url_query_pairs; use crate::log::*; use crate::AggKind; diff --git a/crates/netpod/src/query/api1.rs b/crates/netpod/src/query/api1.rs index 143f538..7fed861 100644 --- a/crates/netpod/src/query/api1.rs +++ b/crates/netpod/src/query/api1.rs @@ -1,7 +1,11 @@ use crate::query::datetime::Datetime; -use crate::{DiskIoTune, FileIoBufferSize, ReadSys}; +use crate::DiskIoTune; +use crate::FileIoBufferSize; +use crate::ReadSys; +use daqbuf_err as err; use err::Error; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; +use serde::Serialize; use std::fmt; use std::time::Duration; diff --git a/crates/netpod/src/query/datetime.rs b/crates/netpod/src/query/datetime.rs index 3039098..c3d3d2c 100644 --- a/crates/netpod/src/query/datetime.rs +++ b/crates/netpod/src/query/datetime.rs @@ -1,5 +1,6 @@ use chrono::DateTime; use chrono::FixedOffset; +use daqbuf_err as err; use err::Error; use serde::de::Visitor; use serde::Deserialize; diff --git a/crates/netpod/src/range/evrange.rs b/crates/netpod/src/range/evrange.rs index 3d88467..f53e9f0 100644 --- a/crates/netpod/src/range/evrange.rs +++ b/crates/netpod/src/range/evrange.rs @@ -9,6 +9,7 @@ use crate::TsNano; use chrono::DateTime; use chrono::TimeZone; use chrono::Utc; +use daqbuf_err as err; use err::Error; use serde::Deserialize; use serde::Serialize; diff --git a/crates/netpod/src/streamext.rs b/crates/netpod/src/streamext.rs index 27729b0..213b3a1 100644 --- a/crates/netpod/src/streamext.rs +++ b/crates/netpod/src/streamext.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::Error; use futures_util::{Stream, StreamExt}; use std::pin::Pin; diff --git a/crates/netpod/src/ttl.rs b/crates/netpod/src/ttl.rs index 552cdee..33e2e3b 100644 --- a/crates/netpod/src/ttl.rs +++ b/crates/netpod/src/ttl.rs @@ -1,4 +1,5 @@ use core::fmt; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use serde::Deserialize; diff --git a/crates/nodenet/Cargo.toml b/crates/nodenet/Cargo.toml index 1ebef77..16a1568 100644 --- a/crates/nodenet/Cargo.toml +++ b/crates/nodenet/Cargo.toml @@ -17,7 +17,7 @@ byteorder = "1.4.3" futures-util = "0.3.14" tracing = "0.1.25" hex = "0.4.3" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } netpod = { path = "../netpod" } query = { path = "../query" } disk = { path = "../disk" } diff --git a/crates/nodenet/src/channelconfig.rs b/crates/nodenet/src/channelconfig.rs index e4a6d68..8425ceb 100644 --- a/crates/nodenet/src/channelconfig.rs +++ b/crates/nodenet/src/channelconfig.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use dbconn::worker::PgQueue; use err::thiserror; use err::ThisError; diff --git a/crates/nodenet/src/client.rs b/crates/nodenet/src/client.rs index cd72e0c..396d13b 100644 --- a/crates/nodenet/src/client.rs +++ b/crates/nodenet/src/client.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::Error; use futures_util::Future; use futures_util::TryFutureExt; diff --git a/crates/nodenet/src/configquorum.rs b/crates/nodenet/src/configquorum.rs index a91b657..46b448a 100644 --- a/crates/nodenet/src/configquorum.rs +++ b/crates/nodenet/src/configquorum.rs @@ -1,4 +1,5 @@ use crate::channelconfig::http_get_channel_config; +use daqbuf_err as err; use dbconn::worker::PgQueue; use err::thiserror; use err::ThisError; diff --git a/crates/nodenet/src/conn.rs b/crates/nodenet/src/conn.rs index 03462eb..be22ad4 100644 --- a/crates/nodenet/src/conn.rs +++ b/crates/nodenet/src/conn.rs @@ -1,5 +1,6 @@ use crate::scylla::scylla_channel_event_stream; use bytes::Bytes; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use futures_util::Stream; diff --git a/crates/nodenet/src/conn/test.rs b/crates/nodenet/src/conn/test.rs index bf4195b..a04bc2b 100644 --- a/crates/nodenet/src/conn/test.rs +++ b/crates/nodenet/src/conn/test.rs @@ -1,5 +1,6 @@ use crate::conn::events_conn_handler; use crate::conn::Frame1Parts; +use daqbuf_err as err; use err::Error; use futures_util::StreamExt; use items_0::streamitem::sitem_data; diff --git a/crates/nodenet/src/scylla.rs b/crates/nodenet/src/scylla.rs index 5aa5e0c..6a72588 100644 --- a/crates/nodenet/src/scylla.rs +++ b/crates/nodenet/src/scylla.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::thiserror; use err::ThisError; use futures_util::Future; @@ -157,7 +158,7 @@ impl Stream for ScyllaEventsReadStream { self.stream = Some(x); continue; } - Ready(Err(e)) => Ready(Some(Err(::err::Error::from_string(e)))), + Ready(Err(e)) => Ready(Some(Err(err::Error::from_string(e)))), Pending => Pending, } } else if let Some(fut) = self.stream.as_mut() { diff --git a/crates/parse/Cargo.toml b/crates/parse/Cargo.toml index bd4ac20..539550f 100644 --- a/crates/parse/Cargo.toml +++ b/crates/parse/Cargo.toml @@ -8,11 +8,10 @@ edition = "2021" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" humantime-serde = "1.1" -#tokio = { version = "1.28.2", features = ["fs"] } chrono = { version = "0.4.26", features = ["serde"] } bytes = "1.4" byteorder = "1.4" hex = "0.4.3" nom = "7.1.3" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } netpod = { path = "../netpod" } diff --git a/crates/parse/src/api1_parse.rs b/crates/parse/src/api1_parse.rs index cd4c2e3..99fcfa2 100644 --- a/crates/parse/src/api1_parse.rs +++ b/crates/parse/src/api1_parse.rs @@ -1,5 +1,6 @@ use crate::channelconfig::CompressionMethod; use crate::nom; +use daqbuf_err as err; use netpod::log::*; use netpod::ScalarType; use netpod::Shape; diff --git a/crates/parse/src/channelconfig.rs b/crates/parse/src/channelconfig.rs index e7948f6..73611f1 100644 --- a/crates/parse/src/channelconfig.rs +++ b/crates/parse/src/channelconfig.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::*; use netpod::log::*; use netpod::range::evrange::NanoRange; diff --git a/crates/scyllaconn/Cargo.toml b/crates/scyllaconn/Cargo.toml index ccc30b0..74b9cb1 100644 --- a/crates/scyllaconn/Cargo.toml +++ b/crates/scyllaconn/Cargo.toml @@ -12,11 +12,11 @@ futures-util = "0.3.24" pin-project = "1" async-channel = "2.3.1" scylla = "0.13.0" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } netpod = { path = "../netpod" } query = { path = "../query" } items_0 = { path = "../items_0" } items_2 = { path = "../items_2" } streams = { path = "../streams" } -series = { path = "../../../daqingest/series" } +daqbuf-series = { path = "../../../daqbuf-series" } taskrun = { path = "../taskrun" } diff --git a/crates/scyllaconn/src/accounting/toplist.rs b/crates/scyllaconn/src/accounting/toplist.rs index f8b952e..b6369b7 100644 --- a/crates/scyllaconn/src/accounting/toplist.rs +++ b/crates/scyllaconn/src/accounting/toplist.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::thiserror; use err::ThisError; use futures_util::StreamExt; diff --git a/crates/scyllaconn/src/accounting/totals.rs b/crates/scyllaconn/src/accounting/totals.rs index d07fc69..099ad22 100644 --- a/crates/scyllaconn/src/accounting/totals.rs +++ b/crates/scyllaconn/src/accounting/totals.rs @@ -1,4 +1,5 @@ use crate::errconv::ErrConv; +use daqbuf_err as err; use err::Error; use futures_util::Future; use futures_util::FutureExt; diff --git a/crates/scyllaconn/src/conn.rs b/crates/scyllaconn/src/conn.rs index 951341f..3057757 100644 --- a/crates/scyllaconn/src/conn.rs +++ b/crates/scyllaconn/src/conn.rs @@ -1,4 +1,5 @@ use crate::errconv::ErrConv; +use daqbuf_err as err; use err::Error; use netpod::log::*; use netpod::ScyllaConfig; diff --git a/crates/scyllaconn/src/errconv.rs b/crates/scyllaconn/src/errconv.rs index c1fef92..0e47bbf 100644 --- a/crates/scyllaconn/src/errconv.rs +++ b/crates/scyllaconn/src/errconv.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::Error; use scylla::frame::response::cql_to_rust::FromRowError as ScyFromRowError; use scylla::transport::errors::NewSessionError as ScyNewSessionError; diff --git a/crates/scyllaconn/src/events.rs b/crates/scyllaconn/src/events.rs index 99c7080..3270194 100644 --- a/crates/scyllaconn/src/events.rs +++ b/crates/scyllaconn/src/events.rs @@ -3,6 +3,8 @@ use crate::events2::prepare::StmtsEvents; use crate::range::ScyllaSeriesRange; use crate::worker::ScyllaQueue; use core::fmt; +use daqbuf_err as err; +use daqbuf_series::SeriesId; use err::thiserror; use err::ThisError; use futures_util::Future; @@ -22,7 +24,6 @@ use netpod::TsMs; use netpod::TsNano; use scylla::frame::response::result::Row; use scylla::Session; -use series::SeriesId; use std::pin::Pin; use std::sync::Arc; use std::time::Instant; diff --git a/crates/scyllaconn/src/events2/events.rs b/crates/scyllaconn/src/events2/events.rs index cc9bf6b..95b313f 100644 --- a/crates/scyllaconn/src/events2/events.rs +++ b/crates/scyllaconn/src/events2/events.rs @@ -4,6 +4,8 @@ use crate::events::ReadJobTrace; use crate::events::ReadNextValuesOpts; use crate::range::ScyllaSeriesRange; use crate::worker::ScyllaQueue; +use daqbuf_err as err; +use daqbuf_series::SeriesId; use err::thiserror; use err::ThisError; use futures_util::Future; @@ -20,7 +22,6 @@ use netpod::ScalarType; use netpod::Shape; use netpod::TsMs; use netpod::TsMsVecFmt; -use series::SeriesId; use std::collections::VecDeque; use std::pin::Pin; use std::task::Context; diff --git a/crates/scyllaconn/src/events2/firstbefore.rs b/crates/scyllaconn/src/events2/firstbefore.rs index 6a18b2e..7589a71 100644 --- a/crates/scyllaconn/src/events2/firstbefore.rs +++ b/crates/scyllaconn/src/events2/firstbefore.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::thiserror; use err::ThisError; use futures_util::Stream; diff --git a/crates/scyllaconn/src/events2/mergert.rs b/crates/scyllaconn/src/events2/mergert.rs index 238ecac..ffb8fcb 100644 --- a/crates/scyllaconn/src/events2/mergert.rs +++ b/crates/scyllaconn/src/events2/mergert.rs @@ -4,6 +4,7 @@ use super::firstbefore::FirstBeforeAndInside; use crate::events2::firstbefore; use crate::range::ScyllaSeriesRange; use crate::worker::ScyllaQueue; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use futures_util::Future; diff --git a/crates/scyllaconn/src/events2/msp.rs b/crates/scyllaconn/src/events2/msp.rs index eba1004..f33853b 100644 --- a/crates/scyllaconn/src/events2/msp.rs +++ b/crates/scyllaconn/src/events2/msp.rs @@ -1,6 +1,8 @@ use super::prepare::StmtsEvents; use crate::range::ScyllaSeriesRange; use crate::worker::ScyllaQueue; +use daqbuf_err as err; +use daqbuf_series::SeriesId; use err::thiserror; use err::ThisError; use futures_util::Future; @@ -12,7 +14,6 @@ use netpod::ttl::RetentionTime; use netpod::TsMs; use netpod::TsMsVecFmt; use scylla::Session; -use series::SeriesId; use std::collections::VecDeque; use std::pin::Pin; use std::task::Context; diff --git a/crates/scyllaconn/src/events2/prepare.rs b/crates/scyllaconn/src/events2/prepare.rs index 4de5902..ca439ae 100644 --- a/crates/scyllaconn/src/events2/prepare.rs +++ b/crates/scyllaconn/src/events2/prepare.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::thiserror; use err::ThisError; use netpod::ttl::RetentionTime; diff --git a/crates/scyllaconn/src/schema.rs b/crates/scyllaconn/src/schema.rs index 3ce099e..109971d 100644 --- a/crates/scyllaconn/src/schema.rs +++ b/crates/scyllaconn/src/schema.rs @@ -1,3 +1,4 @@ +use daqbuf_err as err; use err::thiserror; use err::ThisError; use netpod::ttl::RetentionTime; diff --git a/crates/scyllaconn/src/scyllaconn.rs b/crates/scyllaconn/src/scyllaconn.rs index 4b1d11b..0a07fc3 100644 --- a/crates/scyllaconn/src/scyllaconn.rs +++ b/crates/scyllaconn/src/scyllaconn.rs @@ -9,8 +9,8 @@ pub mod schema; pub mod status; pub mod worker; +pub use daqbuf_series::SeriesId; pub use scylla; -pub use series::SeriesId; pub async fn test_log() { use netpod::log::*; diff --git a/crates/scyllaconn/src/status.rs b/crates/scyllaconn/src/status.rs index 849d297..be52c22 100644 --- a/crates/scyllaconn/src/status.rs +++ b/crates/scyllaconn/src/status.rs @@ -1,4 +1,5 @@ use crate::errconv::ErrConv; +use daqbuf_err as err; use err::Error; use futures_util::Future; use futures_util::FutureExt; diff --git a/crates/scyllaconn/src/worker.rs b/crates/scyllaconn/src/worker.rs index dad55f8..70eda92 100644 --- a/crates/scyllaconn/src/worker.rs +++ b/crates/scyllaconn/src/worker.rs @@ -5,6 +5,7 @@ use crate::events2::prepare::StmtsEvents; use crate::range::ScyllaSeriesRange; use async_channel::Receiver; use async_channel::Sender; +use daqbuf_err as err; use err::thiserror; use err::ThisError; use futures_util::Future; diff --git a/crates/taskrun/Cargo.toml b/crates/taskrun/Cargo.toml index db1c073..d6c94b6 100644 --- a/crates/taskrun/Cargo.toml +++ b/crates/taskrun/Cargo.toml @@ -16,7 +16,7 @@ tracing-subscriber = { version = "0.3.18", features = ["fmt", "time"] } time = { version = "0.3", features = ["formatting"] } backtrace = "0.3.71" chrono = "0.4.38" -err = { path = "../err" } +daqbuf-err = { path = "../../../daqbuf-err" } [features] diff --git a/crates/taskrun/src/taskrun.rs b/crates/taskrun/src/taskrun.rs index 8cbfcb3..316537e 100644 --- a/crates/taskrun/src/taskrun.rs +++ b/crates/taskrun/src/taskrun.rs @@ -5,6 +5,7 @@ pub use tracing; pub use tracing_subscriber; use crate::log::*; +use daqbuf_err as err; // use console_subscriber::ConsoleLayer; use err::Error; use std::fmt;