pub struct ServiceError<'a> {
pub code: u32,
pub name: Cow<'a, str>,
pub http_status: u16,
pub message: Cow<'a, str>,
pub arguments: Vec<String>,
pub parameters: Option<HashMap<String, ParameterValue>>,
/* private fields */
}Expand description
A ServiceError represents a specific error within the software.
Fields§
§code: u32An internal error code that represents a specific error within the system.
name: Cow<'a, str>A capitalized error name that represents the error type.
http_status: u16The respective HTTP status code that should be returned to the client.
message: Cow<'a, str>A human-readable error message that describes the error in more detail.
arguments: Vec<String>Arguments for message formatting
parameters: Option<HashMap<String, ParameterValue>>Optional parameters as key-value pairs
Implementations§
Source§impl<'a> ServiceError<'a>
impl<'a> ServiceError<'a>
Sourcepub const fn new(
code: u32,
name: &'a str,
status: u16,
message: &'a str,
) -> Self
pub const fn new( code: u32, name: &'a str, status: u16, message: &'a str, ) -> Self
Create a new ServiceError instance.
Sourcepub fn parameter(
self,
key: impl ToString,
value: impl Into<ParameterValue>,
) -> Self
pub fn parameter( self, key: impl ToString, value: impl Into<ParameterValue>, ) -> Self
Add an optional parameter.
Sourcepub fn parameters<K, V, I>(self, params: I) -> Self
pub fn parameters<K, V, I>(self, params: I) -> Self
Add multiple parameters at once.
Sourcepub fn with_response_builder(
self,
builder: impl ResponseBuilder + 'static,
) -> Self
pub fn with_response_builder( self, builder: impl ResponseBuilder + 'static, ) -> Self
Set a custom response builder for formatting the response.
Trait Implementations§
Source§impl<'a> Clone for ServiceError<'a>
impl<'a> Clone for ServiceError<'a>
Source§impl<'a> Debug for ServiceError<'a>
impl<'a> Debug for ServiceError<'a>
Source§impl<'de: 'a, 'a> Deserialize<'de> for ServiceError<'a>
impl<'de: 'a, 'a> Deserialize<'de> for ServiceError<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> IntoResponse for ServiceError<'a>
impl<'a> IntoResponse for ServiceError<'a>
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl<'a> Freeze for ServiceError<'a>
impl<'a> !RefUnwindSafe for ServiceError<'a>
impl<'a> Send for ServiceError<'a>
impl<'a> Sync for ServiceError<'a>
impl<'a> Unpin for ServiceError<'a>
impl<'a> !UnwindSafe for ServiceError<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Call the handler with the given request.
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
Apply a
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Convert the handler into a
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Convert the handler into a
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
Convert the handler into a
MakeService and no state. Read moreSource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
Convert the handler into a
MakeService which stores information
about the incoming connection and has no state. Read more