Remove old thiserror
This commit is contained in:
@@ -28,14 +28,15 @@ use std::time::Duration;
|
||||
const FRAME_HEAD_LEN: usize = 16;
|
||||
const FRAME_PAYLOAD_MAX: u32 = 1024 * 1024 * 80;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "CborStream")]
|
||||
pub enum Error {
|
||||
FromSlice(#[from] std::array::TryFromSliceError),
|
||||
Msg(String),
|
||||
Ciborium(#[from] ciborium::de::Error<std::io::Error>),
|
||||
CiboriumValue(#[from] ciborium::value::Error),
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "CborStream"),
|
||||
enum variants {
|
||||
FromSlice(#[from] std::array::TryFromSliceError),
|
||||
Msg(String),
|
||||
Ciborium(#[from] ciborium::de::Error<std::io::Error>),
|
||||
CiboriumValue(#[from] ciborium::value::Error),
|
||||
},
|
||||
);
|
||||
|
||||
struct ErrMsg<E>(E)
|
||||
where
|
||||
@@ -176,7 +177,7 @@ impl<S> FramedBytesToChannelEventsStream<S> {
|
||||
let n = u32::from_le_bytes(self.buf[..4].try_into()?);
|
||||
if n > FRAME_PAYLOAD_MAX {
|
||||
let e = ErrMsg(format!("frame too large {n}")).into();
|
||||
error!("{e}");
|
||||
error!("{}", e);
|
||||
return Err(e);
|
||||
}
|
||||
let frame_len = FRAME_HEAD_LEN + n as usize;
|
||||
|
||||
@@ -7,11 +7,12 @@ use futures_util::Stream;
|
||||
use futures_util::StreamExt;
|
||||
use items_2::framable::Framable;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "FramedStreamError")]
|
||||
pub enum Error {
|
||||
MakeFrame(#[from] items_2::framable::Error),
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "FramedStreamError"),
|
||||
enum variants {
|
||||
MakeFrame(#[from] items_2::framable::Error),
|
||||
},
|
||||
);
|
||||
|
||||
pub fn frameable_stream_to_bytes_stream<S, T>(stream: S) -> impl Stream<Item = Result<Bytes, Error>>
|
||||
where
|
||||
|
||||
@@ -14,10 +14,6 @@ use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "FromFrames")]
|
||||
pub enum Error {}
|
||||
|
||||
pub struct EventsFromFrames<O, INP> {
|
||||
inp: INP,
|
||||
dbgdesc: String,
|
||||
|
||||
@@ -26,13 +26,14 @@ use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "Generator")]
|
||||
pub enum Error {
|
||||
UnsupportedIsEventBlobs,
|
||||
Items2(#[from] items_2::Error),
|
||||
BadChannelName,
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "Generator"),
|
||||
enum variants {
|
||||
UnsupportedIsEventBlobs,
|
||||
Items2(#[from] items_2::Error),
|
||||
BadChannelName,
|
||||
},
|
||||
);
|
||||
|
||||
fn make_sleep_fut() -> Pin<Box<dyn Future<Output = ()> + Send>> {
|
||||
todo!()
|
||||
@@ -45,7 +46,7 @@ pub fn make_test_channel_events_bytes_stream(
|
||||
) -> Result<BoxedBytesStream, Error> {
|
||||
if subq.is_event_blobs() {
|
||||
let e = Error::UnsupportedIsEventBlobs;
|
||||
error!("{e}");
|
||||
error!("{}", e);
|
||||
Err(e)
|
||||
} else {
|
||||
let stream = make_test_channel_events_stream_data(subq, node_count, node_ix)?;
|
||||
|
||||
@@ -6,9 +6,12 @@ use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "ItemClone")]
|
||||
pub enum Error {}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "ItemClone"),
|
||||
enum variants {
|
||||
Dummy,
|
||||
},
|
||||
);
|
||||
|
||||
#[pin_project::pin_project]
|
||||
pub struct Itemclone<'a, T, INP>
|
||||
|
||||
@@ -12,12 +12,13 @@ use netpod::log::*;
|
||||
use std::pin::Pin;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "JsonStream")]
|
||||
pub enum Error {
|
||||
Json(#[from] serde_json::Error),
|
||||
Msg(String),
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "JsonStream"),
|
||||
enum variants {
|
||||
Json(#[from] serde_json::Error),
|
||||
Msg(String),
|
||||
},
|
||||
);
|
||||
|
||||
pub struct ErrMsg<E>(pub E)
|
||||
where
|
||||
|
||||
@@ -7,9 +7,12 @@ use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "NeedMinBuffer")]
|
||||
pub enum Error {}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "NeedMinBuffer"),
|
||||
enum variants {
|
||||
Dummy,
|
||||
},
|
||||
);
|
||||
|
||||
pub struct NeedMinBuffer {
|
||||
inp: Pin<Box<dyn Stream<Item = Result<FileChunkRead, items_0::streamitem::SitemErrTy>> + Send>>,
|
||||
|
||||
@@ -36,18 +36,32 @@ use std::sync::Arc;
|
||||
|
||||
pub const TEST_BACKEND: &str = "testbackend-00";
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "TcpRawClient")]
|
||||
pub enum Error {
|
||||
IO(#[from] std::io::Error),
|
||||
Msg(String),
|
||||
Frame(#[from] items_2::frame::Error),
|
||||
Framable(#[from] items_2::framable::Error),
|
||||
Json(#[from] serde_json::Error),
|
||||
Http(#[from] http::Error),
|
||||
#[error("ServerError({0:?}, {1})")]
|
||||
ServerError(http::response::Parts, String),
|
||||
HttpBody(Box<dyn std::error::Error + Send>),
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "TcpRawClient"),
|
||||
enum variants {
|
||||
IO(#[from] std::io::Error),
|
||||
Msg(String),
|
||||
Frame(#[from] items_2::frame::Error),
|
||||
Framable(#[from] items_2::framable::Error),
|
||||
Json(#[from] serde_json::Error),
|
||||
Http(#[from] http::Error),
|
||||
ServerError(DisplayDebug<http::response::Parts>, String),
|
||||
// ServerError(http::response::Parts, String),
|
||||
HttpBody(Box<dyn std::error::Error + Send>),
|
||||
},
|
||||
);
|
||||
|
||||
struct DisplayDebug<T: fmt::Debug>(T);
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for DisplayDebug<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Debug::fmt(&self.0, fmt)
|
||||
}
|
||||
}
|
||||
impl<T: fmt::Debug> fmt::Display for DisplayDebug<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Debug::fmt(&self.0, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
struct ErrMsg<E>(E)
|
||||
@@ -86,11 +100,12 @@ pub fn make_node_command_frame(query: EventsSubQuery) -> Result<EventQueryJsonSt
|
||||
Ok(EventQueryJsonStringFrame(ret))
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ErrorBody {
|
||||
#[error("{0}")]
|
||||
Msg(String),
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(ErrorBody, "BodyError"),
|
||||
enum variants {
|
||||
Msg(String),
|
||||
},
|
||||
);
|
||||
|
||||
pub trait HttpSimplePost: Send {
|
||||
fn http_simple_post(
|
||||
@@ -157,7 +172,7 @@ pub async fn x_processed_event_blobs_stream_from_node_http(
|
||||
error!("server error {:?}", head);
|
||||
let buf = read_body_bytes(body).await?;
|
||||
let s = String::from_utf8_lossy(&buf);
|
||||
return Err(Error::ServerError(head, s.to_string()));
|
||||
return Err(Error::ServerError(DisplayDebug(head), s.to_string()));
|
||||
}
|
||||
let (_head, body) = res.into_parts();
|
||||
let inp = body;
|
||||
|
||||
@@ -16,20 +16,21 @@ use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
||||
macro_rules! debug_first { ($($arg:tt)*) => ( if false { debug!($($arg)*); } ) }
|
||||
macro_rules! debug_first { ($($arg:expr),*) => ( if false { debug!($($arg),*); } ) }
|
||||
|
||||
macro_rules! trace2 { ($($arg:tt)*) => ( if false { trace!($($arg)*); } ) }
|
||||
macro_rules! trace2 { ($($arg:expr),*) => ( if false { trace!($($arg),*); } ) }
|
||||
|
||||
macro_rules! trace3 { ($($arg:tt)*) => ( if false { trace!($($arg)*); } ) }
|
||||
macro_rules! trace3 { ($($arg:expr),*) => ( if false { trace!($($arg),*); } ) }
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[cstm(name = "TimeBinnedStream")]
|
||||
pub enum Error {
|
||||
MissingBinnerAfterProcessItem,
|
||||
CreateEmpty,
|
||||
NoBinnerAfterInputDone,
|
||||
Msg(String),
|
||||
}
|
||||
autoerr::create_error_v1!(
|
||||
name(Error, "TimeBinnedStream"),
|
||||
enum variants {
|
||||
MissingBinnerAfterProcessItem,
|
||||
CreateEmpty,
|
||||
NoBinnerAfterInputDone,
|
||||
Msg(String),
|
||||
},
|
||||
);
|
||||
|
||||
type SitemtyStream<T> = Pin<Box<dyn Stream<Item = Sitemty<T>> + Send>>;
|
||||
|
||||
@@ -134,7 +135,7 @@ where
|
||||
Ok(Break(Ready(sitem_data(bins))))
|
||||
} else {
|
||||
let e = Error::CreateEmpty;
|
||||
error!("{e}");
|
||||
error!("{}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user