Generate and read channel config for test case
This commit is contained in:
@@ -8,6 +8,7 @@ edition = "2018"
|
||||
hyper = { version = "0.14", features = ["http1", "http2", "client", "server", "tcp"] }
|
||||
http = "0.2"
|
||||
tokio = { version = "1.5.0", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] }
|
||||
backtrace = "0.3.56"
|
||||
serde_json = "1.0"
|
||||
async-channel = "1.6"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
|
||||
@@ -4,32 +4,41 @@ use std::num::ParseIntError;
|
||||
use std::string::FromUtf8Error;
|
||||
use tokio::task::JoinError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
msg: String,
|
||||
trace: backtrace::Backtrace,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn with_msg<S: Into<String>>(s: S) -> Self {
|
||||
Self { msg: s.into() }
|
||||
Self {
|
||||
msg: s.into(),
|
||||
trace: backtrace::Backtrace::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Error {
|
||||
fn from(k: String) -> Self {
|
||||
Self { msg: k }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Error {
|
||||
fn from(k: &str) -> Self {
|
||||
Self { msg: k.into() }
|
||||
impl std::fmt::Debug for Error {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(fmt, "Error {} backtrace:\n{:?}", self.msg, self.trace)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(fmt, "Error")
|
||||
write!(fmt, "Error {} backtrace:\n{:?}", self.msg, self.trace)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Error {
|
||||
fn from(k: String) -> Self {
|
||||
Self::with_msg(k)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Error {
|
||||
fn from(k: &str) -> Self {
|
||||
Self::with_msg(k)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,49 +46,49 @@ impl std::error::Error for Error {}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
fn from(k: std::io::Error) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<http::Error> for Error {
|
||||
fn from(k: http::Error) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<hyper::Error> for Error {
|
||||
fn from(k: hyper::Error) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
fn from(k: serde_json::Error) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<async_channel::RecvError> for Error {
|
||||
fn from(k: async_channel::RecvError) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<chrono::format::ParseError> for Error {
|
||||
fn from(k: chrono::format::ParseError) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ParseIntError> for Error {
|
||||
fn from(k: ParseIntError) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FromUtf8Error> for Error {
|
||||
fn from(k: FromUtf8Error) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
Self::with_msg(k.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +115,5 @@ impl From<JoinError> for Error {
|
||||
}
|
||||
|
||||
pub fn todoval<T>() -> T {
|
||||
if true {
|
||||
todo!("TODO todoval");
|
||||
}
|
||||
todo!()
|
||||
todo!("TODO todoval")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user