add standard error trait and thread access error conversions
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
5167e1f06d
commit
98d8e5c63c
1 changed files with 10 additions and 4 deletions
|
@ -4,7 +4,7 @@ mod panic;
|
||||||
mod response;
|
mod response;
|
||||||
mod serde;
|
mod serde;
|
||||||
|
|
||||||
use std::{any::Any, borrow::Cow, convert::Infallible, fmt, sync::PoisonError};
|
use std::{any::Any, borrow::Cow, convert::Infallible, sync::PoisonError};
|
||||||
|
|
||||||
pub use self::{err::visit, log::*};
|
pub use self::{err::visit, log::*};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ pub enum Error {
|
||||||
|
|
||||||
// std
|
// std
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Fmt(#[from] fmt::Error),
|
Fmt(#[from] std::fmt::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
FromUtf8(#[from] std::string::FromUtf8Error),
|
FromUtf8(#[from] std::string::FromUtf8Error),
|
||||||
#[error("I/O error: {0}")]
|
#[error("I/O error: {0}")]
|
||||||
|
@ -27,6 +27,10 @@ pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ParseInt(#[from] std::num::ParseIntError),
|
ParseInt(#[from] std::num::ParseIntError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
Std(#[from] Box<dyn std::error::Error + Send>),
|
||||||
|
#[error(transparent)]
|
||||||
|
ThreadAccessError(#[from] std::thread::AccessError),
|
||||||
|
#[error(transparent)]
|
||||||
TryFromInt(#[from] std::num::TryFromIntError),
|
TryFromInt(#[from] std::num::TryFromIntError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
TryFromSlice(#[from] std::array::TryFromSliceError),
|
TryFromSlice(#[from] std::array::TryFromSliceError),
|
||||||
|
@ -189,8 +193,10 @@ impl Error {
|
||||||
pub fn is_not_found(&self) -> bool { self.status_code() == http::StatusCode::NOT_FOUND }
|
pub fn is_not_found(&self) -> bool { self.status_code() == http::StatusCode::NOT_FOUND }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Error {
|
impl std::fmt::Debug for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.message()) }
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.message())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<PoisonError<T>> for Error {
|
impl<T> From<PoisonError<T>> for Error {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue