pub struct ApiError {
pub code: ErrorCode,
pub message: String,
pub details: Option<String>,
pub error_key: Option<String>,
pub path: Option<String>,
pub validation_errors: Vec<ValidationError>,
pub timestamp: DateTime<Utc>,
pub trace_id: Option<String>,
}Available on crate feature
core only.Fields§
§code: ErrorCode§message: String§details: Option<String>§error_key: Option<String>§path: Option<String>§validation_errors: Vec<ValidationError>§timestamp: DateTime<Utc>§trace_id: Option<String>Implementations§
Source§impl ApiError
impl ApiError
pub fn new(code: ErrorCode, message: impl Into<String>) -> ApiError
pub fn with_details(self, details: impl Into<String>) -> ApiError
pub fn with_error_key(self, key: impl Into<String>) -> ApiError
pub fn with_path(self, path: impl Into<String>) -> ApiError
pub fn with_validation_errors(self, errors: Vec<ValidationError>) -> ApiError
pub fn with_trace_id(self, id: impl Into<String>) -> ApiError
pub fn not_found(message: impl Into<String>) -> ApiError
pub fn bad_request(message: impl Into<String>) -> ApiError
pub fn forbidden(message: impl Into<String>) -> ApiError
pub fn internal_error(message: impl Into<String>) -> ApiError
pub fn validation_error( message: impl Into<String>, errors: Vec<ValidationError>, ) -> ApiError
pub fn conflict(message: impl Into<String>) -> ApiError
Trait Implementations§
Source§impl ApiErrorExt for ApiError
impl ApiErrorExt for ApiError
fn with_request_context(self, ctx: &RequestContext) -> ApiError
Source§impl<'de> Deserialize<'de> for ApiError
impl<'de> Deserialize<'de> for ApiError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ApiError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ApiError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<InternalApiError> for ApiError
impl From<InternalApiError> for ApiError
Source§fn from(error: InternalApiError) -> ApiError
fn from(error: InternalApiError) -> ApiError
Converts to this type from the input type.
Source§impl From<RepositoryError> for ApiError
impl From<RepositoryError> for ApiError
Source§fn from(err: RepositoryError) -> ApiError
fn from(err: RepositoryError) -> ApiError
Converts to this type from the input type.
Source§impl From<ServiceError> for ApiError
impl From<ServiceError> for ApiError
Source§fn from(err: ServiceError) -> ApiError
fn from(err: ServiceError) -> ApiError
Converts to this type from the input type.
Source§impl Serialize for ApiError
impl Serialize for ApiError
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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<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