From 98d8e5c63cc7019d6ecbe235f380a3c954b9e6b5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 16 Jan 2025 08:00:01 +0000 Subject: [PATCH] add standard error trait and thread access error conversions Signed-off-by: Jason Volk --- src/core/error/mod.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/error/mod.rs b/src/core/error/mod.rs index ffa829d9..2468811e 100644 --- a/src/core/error/mod.rs +++ b/src/core/error/mod.rs @@ -4,7 +4,7 @@ mod panic; mod response; 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::*}; @@ -17,7 +17,7 @@ pub enum Error { // std #[error(transparent)] - Fmt(#[from] fmt::Error), + Fmt(#[from] std::fmt::Error), #[error(transparent)] FromUtf8(#[from] std::string::FromUtf8Error), #[error("I/O error: {0}")] @@ -27,6 +27,10 @@ pub enum Error { #[error(transparent)] ParseInt(#[from] std::num::ParseIntError), #[error(transparent)] + Std(#[from] Box), + #[error(transparent)] + ThreadAccessError(#[from] std::thread::AccessError), + #[error(transparent)] TryFromInt(#[from] std::num::TryFromIntError), #[error(transparent)] 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 } } -impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.message()) } +impl std::fmt::Debug for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.message()) + } } impl From> for Error {