Struct xitca_web::error::ThreadJoinError
source · pub struct ThreadJoinError(pub Mutex<Box<dyn Any + Send>>);Expand description
error happens when joining a thread. typically caused by code panic inside thread.
CatchUnwind middleware is able to produce this error type.
§Examples:
fn handle_error(e: &ThreadJoinError) {
// debug and display format thread join error. can only provide basic error message if the error
// source is typical string.(for example generated by panic! macro or unwrap/expect methods)
println!("{e:?}");
println!("{e}");
// for arbitrary thread join error manual type downcast is needed.(for example generated by std::panic::panic_any)
// the mutex lock inside is to satisfy xitca-web's error type's thread safe guarantee: Send and Sync auto traits.
//
// rust's std library only offers Send bound for thread join error and the mutex is solely for the purpose of making
// the error bound to Send + Sync.
let any = e.0.lock().unwrap();
// an arbitrary type we assume possibly being used as panic message.
struct Foo;
if let Some(_foo) = any.downcast_ref::<Foo>() {
// if downcast is succeed it's possible to handle the typed panic message.
}
// otherwise there is basically no way to retrieve any meaningful information and it's best to just ignore the error.
// xitca-web is able to generate minimal http response from it anyway.
}Tuple Fields§
§0: Mutex<Box<dyn Any + Send>>Trait Implementations§
source§impl Debug for ThreadJoinError
impl Debug for ThreadJoinError
source§impl Display for ThreadJoinError
impl Display for ThreadJoinError
source§impl Error for ThreadJoinError
impl Error for ThreadJoinError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl<C> From<ThreadJoinError> for Error<C>
impl<C> From<ThreadJoinError> for Error<C>
source§fn from(e: ThreadJoinError) -> Self
fn from(e: ThreadJoinError) -> Self
Converts to this type from the input type.
source§impl<'r, C, B> Service<WebContext<'r, C, B>> for ThreadJoinError
impl<'r, C, B> Service<WebContext<'r, C, B>> for ThreadJoinError
§type Response = Response<ResponseBody>
type Response = Response<ResponseBody>
The Ok part of output future.
§type Error = Infallible
type Error = Infallible
The Err part of output future.
async fn call( &self, ctx: WebContext<'r, C, B> ) -> Result<Self::Response, Self::Error>
Auto Trait Implementations§
impl RefUnwindSafe for ThreadJoinError
impl Send for ThreadJoinError
impl Sync for ThreadJoinError
impl Unpin for ThreadJoinError
impl UnwindSafe for ThreadJoinError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<S, Arg> ServiceExt<Arg> for Swhere
S: Service<Arg>,
impl<S, Arg> ServiceExt<Arg> for Swhere
S: Service<Arg>,
source§fn enclosed<T>(self, build: T) -> Pipeline<Self, T, BuildEnclosed>
fn enclosed<T>(self, build: T) -> Pipeline<Self, T, BuildEnclosed>
Enclose Self with given
T as Service<<Self as Service<_>>::Response>>. In other word T
would take Self’s Service::Response type as it’s generic argument of Service<_> impl.source§fn enclosed_fn<T, Req>(self, func: T) -> Pipeline<Self, T, BuildEnclosedFn>
fn enclosed_fn<T, Req>(self, func: T) -> Pipeline<Self, T, BuildEnclosedFn>
Function version of Self::enclosed method.
source§fn map<F, Res, ResMap>(self, mapper: F) -> Pipeline<Self, F, BuildMap>
fn map<F, Res, ResMap>(self, mapper: F) -> Pipeline<Self, F, BuildMap>
Mutate
<<Self::Response as Service<Req>>::Future as Future>::Output type with given
closure.