pub struct TonicStatusWrapper {
inner: Status,
call: Option<String>,
client_side_service_name: Option<Cow<'static, str>>,
}Expand description
A wrapper of tonic::Status that provides better error message and extracts
the source chain from the details field.
Fields§
§inner: Status§call: Option<String>The call name (path) of the gRPC request.
client_side_service_name: Option<Cow<'static, str>>Optional service name from the client side.
§Explanation
tonic::Status is used for both client and server side. When the error is created on
the server side, we encourage developers to provide the service name with
ToTonicStatus::to_status, so that the info can be included in the HTTP response and
then extracted by the client side (in TonicStatusWrapper::new).
However, if there’s something wrong with the server side and the error is directly
created on the client side, the approach above is not applicable. In this case, the
caller should set a “client side” service name to provide better error message. This is
achieved by TonicStatusWrapperExt::with_client_side_service_name.
Implementations§
Source§impl TonicStatusWrapper
impl TonicStatusWrapper
Sourcepub fn new(status: Status) -> Self
pub fn new(status: Status) -> Self
Create a new TonicStatusWrapper from the given tonic::Status and extract
the source chain from its details field.
Sourcepub fn inner(&self) -> &Status
pub fn inner(&self) -> &Status
Returns the reference to the inner tonic::Status.
Sourcepub fn into_inner(self) -> Status
pub fn into_inner(self) -> Status
Consumes self and returns the inner tonic::Status.
Trait Implementations§
Source§impl Debug for TonicStatusWrapper
impl Debug for TonicStatusWrapper
Source§impl Display for TonicStatusWrapper
impl Display for TonicStatusWrapper
Source§impl Error for TonicStatusWrapper
impl Error for TonicStatusWrapper
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Source§fn provide<'a>(&'a self, request: &mut Request<'a>)
fn provide<'a>(&'a self, request: &mut Request<'a>)
error_generic_member_access)1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl !Freeze for TonicStatusWrapper
impl !RefUnwindSafe for TonicStatusWrapper
impl Send for TonicStatusWrapper
impl Sync for TonicStatusWrapper
impl Unpin for TonicStatusWrapper
impl !UnwindSafe for TonicStatusWrapper
Blanket Implementations§
§impl<T> AsReport for Twhere
T: Error,
impl<T> AsReport for Twhere
T: Error,
§fn to_report_string(&self) -> String
fn to_report_string(&self) -> String
§fn to_report_string_with_backtrace(&self) -> String
fn to_report_string_with_backtrace(&self) -> String
§fn to_report_string_pretty(&self) -> String
fn to_report_string_pretty(&self) -> String
§fn to_report_string_pretty_with_backtrace(&self) -> String
fn to_report_string_pretty_with_backtrace(&self) -> String
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
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any.Source§impl<T> ErrorIsFromTonicServerImpl for T
impl<T> ErrorIsFromTonicServerImpl for T
Source§fn is_from_tonic_server_impl(&self) -> bool
fn is_from_tonic_server_impl(&self) -> bool
ToTonicStatus::to_status. Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.