#[non_exhaustive]pub struct ErrorResponse<Meta> {
pub error: ApiError,
pub meta: Option<Meta>,
}
Expand description
Struct to represent an error response
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.error: ApiError
§meta: Option<Meta>
Implementations§
Source§impl<Meta> ErrorResponse<Meta>
impl<Meta> ErrorResponse<Meta>
pub const fn new(error: ApiError, meta: Meta) -> Self
pub const fn from_error(error: ApiError) -> Self
pub fn from_error_msg(code: impl Into<u32>, message: impl Into<String>) -> Self
pub fn from_error_source( code: impl Into<u32>, source: impl Error + Send + Sync + 'static, set_source_detail: bool, message: impl Into<MaybeString>, ) -> Self
pub fn with_meta(self, meta: Meta) -> Self
pub fn set_meta(&mut self, meta: Meta) -> &mut Self
pub fn with_detail( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
pub fn set_detail( &mut self, key: impl Into<String>, value: impl Into<String>, ) -> &mut Self
pub fn with_source( self, source: impl Error + Send + Sync + 'static, set_source_detail: bool, ) -> Self
pub fn set_source( &mut self, source: impl Error + Send + Sync + 'static, set_source_detail: bool, ) -> &mut Self
pub const fn code(&self) -> u32
pub const fn message(&self) -> &String
pub fn details(&self) -> Option<&HashMap<String, String>>
pub fn detail(&self, key: impl AsRef<str>) -> Option<&String>
pub fn is<E: Error + 'static>(&self) -> bool
pub fn downcast_ref<E: Error + 'static>(&self) -> Option<&E>
Trait Implementations§
Source§impl<Meta: Debug> Debug for ErrorResponse<Meta>
impl<Meta: Debug> Debug for ErrorResponse<Meta>
Source§impl<'de, Meta> Deserialize<'de> for ErrorResponse<Meta>where
Meta: Deserialize<'de>,
impl<'de, Meta> Deserialize<'de> for ErrorResponse<Meta>where
Meta: Deserialize<'de>,
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<Meta> Display for ErrorResponse<Meta>
impl<Meta> Display for ErrorResponse<Meta>
Source§impl<Meta: Debug> Error for ErrorResponse<Meta>
impl<Meta: Debug> Error for ErrorResponse<Meta>
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<Meta> From<ApiError> for ErrorResponse<Meta>
impl<Meta> From<ApiError> for ErrorResponse<Meta>
Source§impl<Data, Meta> From<ErrorResponse<Meta>> for ApiResponse<Data, Meta>
impl<Data, Meta> From<ErrorResponse<Meta>> for ApiResponse<Data, Meta>
Source§fn from(value: ErrorResponse<Meta>) -> Self
fn from(value: ErrorResponse<Meta>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<Meta> Freeze for ErrorResponse<Meta>where
Meta: Freeze,
impl<Meta> !RefUnwindSafe for ErrorResponse<Meta>
impl<Meta> Send for ErrorResponse<Meta>where
Meta: Send,
impl<Meta> Sync for ErrorResponse<Meta>where
Meta: Sync,
impl<Meta> Unpin for ErrorResponse<Meta>where
Meta: Unpin,
impl<Meta> !UnwindSafe for ErrorResponse<Meta>
Blanket Implementations§
Source§impl<Data> ApiSuccessResponse for Data
impl<Data> ApiSuccessResponse for Data
fn api_response<Meta>(self, meta: Option<Meta>) -> ApiResponse<Self, Meta>
fn api_response_without_meta<Meta>(self) -> ApiResponse<Self, Meta>
fn api_response_with_meta<Meta>(self, meta: Meta) -> ApiResponse<Self, Meta>
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