This commit is contained in:
Dominik Werder
2021-04-21 10:39:16 +02:00
parent 3e53f17acb
commit f8921faf63
10 changed files with 154 additions and 55 deletions

View File

@@ -4,6 +4,7 @@ Error handling and reporting.
use nom::error::ErrorKind;
use std::fmt::Debug;
use std::net::AddrParseError;
use std::num::ParseIntError;
use std::string::FromUtf8Error;
use tokio::task::JoinError;
@@ -35,15 +36,23 @@ impl std::fmt::Debug for Error {
None => false,
Some(s) => s.to_str().unwrap().contains("dev/daqbuffer"),
};
if is_ours {
write!(
&mut buf,
"\n {}\n {} {}",
sy.name().unwrap(),
sy.filename().unwrap().to_str().unwrap(),
sy.lineno().unwrap(),
)
.unwrap();
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 true || is_ours {
write!(&mut buf, "\n {}\n {} {}", name, filename, lineno).unwrap();
}
}
}
@@ -78,6 +87,12 @@ impl From<std::io::Error> for Error {
}
}
impl From<AddrParseError> for Error {
fn from(k: AddrParseError) -> Self {
Self::with_msg(k.to_string())
}
}
impl From<http::Error> for Error {
fn from(k: http::Error) -> Self {
Self::with_msg(k.to_string())