pub struct ServerError {
pub status_code: Option<StatusCode>,
pub public_msg: Option<String>,
pub private_msg: Option<Vec<String>>,
}
Expand description
Data structure responsible for server errors.
Fields§
§status_code: Option<StatusCode>
Status code to return.
public_msg: Option<String>
Text to return (and hide error messages that leads to leak vulnerable data).
private_msg: Option<Vec<String>>
Text that really describes error situation.
Implementations§
Source§impl ServerError
impl ServerError
Sourcepub fn from_private(err: impl Error + 'static) -> ServerError
pub fn from_private(err: impl Error + 'static) -> ServerError
Makes a new ServerError with actual error.
Sourcepub fn from_private_str(err: impl Into<String>) -> ServerError
pub fn from_private_str(err: impl Into<String>) -> ServerError
Makes a new ServerError with actual error provided by plain string.
Sourcepub fn with_private_str(self, new_private_msg: impl Into<String>) -> ServerError
pub fn with_private_str(self, new_private_msg: impl Into<String>) -> ServerError
Adds a private message to the ServerError.
Sourcepub fn with_public(self, new_public_msg: impl Into<String>) -> ServerError
pub fn with_public(self, new_public_msg: impl Into<String>) -> ServerError
Adds a public message to the ServerError.
If ServerError already have a public message, it goes to private messages stack.
Sourcepub fn from_public(public_msg: impl Into<String>) -> ServerError
pub fn from_public(public_msg: impl Into<String>) -> ServerError
Makes a new Server Error from public message.
Sourcepub fn with_400(self) -> ServerError
pub fn with_400(self) -> ServerError
Error BAD REQUEST (400).
Sourcepub fn with_401(self) -> ServerError
pub fn with_401(self) -> ServerError
Error UNAUTHORIZED (401).
Sourcepub fn with_403(self) -> ServerError
pub fn with_403(self) -> ServerError
Error FORBIDDEN (403).
Sourcepub fn with_404(self) -> ServerError
pub fn with_404(self) -> ServerError
Error NOT FOUND (404).
Sourcepub fn with_405(self) -> ServerError
pub fn with_405(self) -> ServerError
Error METHOD NOT ALLOWED (405).
Sourcepub fn with_500(self) -> ServerError
pub fn with_500(self) -> ServerError
Error INTERNAL SERVER ERROR (500).
Sourcepub fn with_code(self, code: StatusCode) -> ServerError
pub fn with_code(self, code: StatusCode) -> ServerError
Error LOCKED (423).
Sourcepub fn bail<T>(self) -> Result<T, ServerError>
pub fn bail<T>(self) -> Result<T, ServerError>
Converts the ServerError into Result::Err.
Trait Implementations§
Source§impl Clone for ServerError
impl Clone for ServerError
Source§fn clone(&self) -> ServerError
fn clone(&self) -> ServerError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ServerError
impl Debug for ServerError
Source§impl Display for ServerError
impl Display for ServerError
Source§impl EndpointOutRegister for ServerError
impl EndpointOutRegister for ServerError
Source§fn register(components: &mut Components, operation: &mut Operation)
fn register(components: &mut Components, operation: &mut Operation)
Registers error types for OpenAPI.
Source§impl Error for ServerError
impl Error for ServerError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl ExplicitServerWrite for ServerError
impl ExplicitServerWrite for ServerError
Source§async fn explicit_write(self, res: &mut Response)
async fn explicit_write(self, res: &mut Response)
Response
object.Source§impl Writer for ServerError
impl Writer for ServerError
Source§fn write<'life0, 'life1, 'life2, 'async_trait>(
self,
_req: &'life0 mut Request,
_depot: &'life1 mut Depot,
res: &'life2 mut Response,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
ServerError: 'async_trait,
fn write<'life0, 'life1, 'life2, 'async_trait>(
self,
_req: &'life0 mut Request,
_depot: &'life1 mut Depot,
res: &'life2 mut Response,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
ServerError: 'async_trait,
Method for sending an error message to the client.
Auto Trait Implementations§
impl Freeze for ServerError
impl RefUnwindSafe for ServerError
impl Send for ServerError
impl Sync for ServerError
impl Unpin for ServerError
impl UnwindSafe for ServerError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.