pub struct ApiError { /* private fields */ }Expand description
Struct to represent error information
Implementations§
Source§impl ApiError
impl ApiError
pub fn new(code: impl Into<u32>, message: impl Into<String>) -> Self
pub fn from_source( code: impl Into<u32>, source: impl Error + Send + Sync + 'static, set_source_detail: bool, message: impl Into<MaybeString>, ) -> Self
pub fn with_code(self, code: impl Into<u32>) -> Self
pub fn with_message(self, message: impl Into<String>) -> Self
pub fn with_details(self, details: HashMap<String, String>) -> 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>
pub const fn api_response<Data, Meta>( self, meta: Option<Meta>, ) -> ApiResponse<Data, Meta>
pub const fn api_response_without_meta<Data, Meta>(
self,
) -> ApiResponse<Data, Meta>where
Self: Sized,
pub const fn api_response_with_meta<Data, Meta>(
self,
meta: Meta,
) -> ApiResponse<Data, Meta>where
Self: Sized,
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ApiError
impl<'de> Deserialize<'de> for ApiError
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 Error for ApiError
impl Error for ApiError
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<Data, Meta> From<ApiError> for ApiResponse<Data, Meta>
impl<Data, Meta> From<ApiError> for ApiResponse<Data, Meta>
Source§impl<Meta> From<ApiError> for ErrorResponse<Meta>
impl<Meta> From<ApiError> for ErrorResponse<Meta>
Auto Trait Implementations§
impl Freeze for ApiError
impl !RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
impl !UnwindSafe for ApiError
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