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)>
Returns 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 From<ThreadJoinError> for Error
impl From<ThreadJoinError> for Error
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
Auto Trait Implementations§
impl !Freeze for ThreadJoinError
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, O>(
self,
func: T,
) -> Pipeline<Self, AsyncFn<T>, BuildEnclosed>
fn enclosed_fn<T, Req, O>( self, func: T, ) -> Pipeline<Self, AsyncFn<T>, BuildEnclosed>
Function version of Self::enclosed method.
Source§fn map<F, Res, ResMap>(self, mapper: F) -> Pipeline<Self, Map<F>, BuildEnclosed>
fn map<F, Res, ResMap>(self, mapper: F) -> Pipeline<Self, Map<F>, BuildEnclosed>
Mutate
<<Self::Response as Service<Req>>::Future as Future>::Output
type with given
closure.