pub enum Error {
Business {
code: i32,
message: String,
details: Option<String>,
},
Validation {
field: String,
message: String,
},
NotFound {
resource: String,
id: String,
},
Unauthorized {
message: String,
},
Forbidden {
message: String,
},
Database {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Internal {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Custom {
code: i32,
message: String,
status: u16,
details: Option<String>,
},
}Variants§
Implementations§
Source§impl Error
impl Error
pub fn business(code: i32, message: impl Into<String>) -> Self
pub fn business_with_details( code: i32, message: impl Into<String>, details: impl Into<String>, ) -> Self
pub fn validation(field: impl Into<String>, message: impl Into<String>) -> Self
pub fn not_found(resource: impl Into<String>, id: impl Into<String>) -> Self
pub fn forbidden(message: impl Into<String>) -> Self
pub fn database(message: impl Into<String>) -> Self
pub fn database_with_source( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
pub fn internal(message: impl Into<String>) -> Self
pub fn internal_with_source( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
pub fn custom(code: i32, message: impl Into<String>, status: u16) -> Self
pub fn custom_with_details( code: i32, message: impl Into<String>, status: u16, details: impl Into<String>, ) -> Self
pub fn status_code(&self) -> u16
pub fn error_code(&self) -> i32
pub fn error_message(&self) -> String
pub fn error_details(&self) -> Option<String>
pub fn to_response(&self) -> Response
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe for Error
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