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) -> Self
pub fn from_private(err: impl Error + 'static) -> Self
Makes a new ServerError with actual error.
Sourcepub fn from_private_str(err: impl Into<String>) -> Self
pub fn from_private_str(err: impl Into<String>) -> Self
Makes a new ServerError with actual error provided by plain string.
Sourcepub fn with_private_str(self, new_private_msg: impl Into<String>) -> Self
pub fn with_private_str(self, new_private_msg: impl Into<String>) -> Self
Adds a private message to the ServerError.
Sourcepub fn with_public(self, new_public_msg: impl Into<String>) -> Self
pub fn with_public(self, new_public_msg: impl Into<String>) -> Self
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>) -> Self
pub fn from_public(public_msg: impl Into<String>) -> Self
Makes a new Server Error from public message.
Sourcepub fn with_code(self, code: StatusCode) -> Self
pub fn with_code(self, code: StatusCode) -> Self
Adds any status code you need.
Trait Implementations§
Source§impl Clone for ServerError
impl Clone for ServerError
Source§fn clone(&self) -> ServerError
fn clone(&self) -> ServerError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ServerError
Available on crate feature mresult only.
impl Debug for ServerError
Available on crate feature
mresult only.Source§impl Display for ServerError
Available on crate feature mresult only.
impl Display for ServerError
Available on crate feature
mresult only.Source§impl EndpointOutRegister for ServerError
Available on crate feature salvo and crate feature mresult and neither WebAssembly nor WebAssembly only.
impl EndpointOutRegister for ServerError
Available on crate feature
salvo and crate feature mresult and neither WebAssembly nor WebAssembly only.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
Available on crate feature mresult only.
impl Error for ServerError
Available on crate feature
mresult only.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 ExplicitServerWrite for ServerError
Available on crate feature salvo and crate feature mresult and neither WebAssembly nor WebAssembly only.
impl ExplicitServerWrite for ServerError
Available on crate feature
salvo and crate feature mresult and neither WebAssembly nor WebAssembly only.Source§async fn explicit_write(self, res: &mut Response)
async fn explicit_write(self, res: &mut Response)
Write an actual response in a
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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: '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
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> 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>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
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.