pub struct TonicStatusWrapper {
inner: Status,
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
§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
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> 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