pub enum HttpError {
Show 15 variants
StartupFailed {
message: String,
},
ShutdownFailed {
message: String,
},
ConfigError {
message: String,
},
ServiceResolutionFailed {
service: String,
},
RequestTimeout,
RequestTooLarge {
size: usize,
limit: usize,
},
BadRequest {
message: String,
},
InternalError {
message: String,
},
HealthCheckFailed {
reason: String,
},
DatabaseError {
message: String,
},
ValidationError {
message: String,
},
NotFound {
resource: String,
},
Conflict {
message: String,
},
Unauthorized,
Forbidden {
message: String,
},
}Expand description
HTTP server errors
Variants§
StartupFailed
ShutdownFailed
ConfigError
ServiceResolutionFailed
RequestTimeout
RequestTooLarge
BadRequest
InternalError
HealthCheckFailed
DatabaseError
ValidationError
NotFound
Conflict
Forbidden
Implementations§
Source§impl HttpError
impl HttpError
Sourcepub fn service_resolution<T: Into<String>>(service: T) -> Self
pub fn service_resolution<T: Into<String>>(service: T) -> Self
Create a service resolution error
Sourcepub fn bad_request<T: Into<String>>(message: T) -> Self
pub fn bad_request<T: Into<String>>(message: T) -> Self
Create a bad request error
Sourcepub fn health_check<T: Into<String>>(reason: T) -> Self
pub fn health_check<T: Into<String>>(reason: T) -> Self
Create a health check error
Sourcepub fn database_error<T: Into<String>>(message: T) -> Self
pub fn database_error<T: Into<String>>(message: T) -> Self
Create a database error
Sourcepub fn validation_error<T: Into<String>>(message: T) -> Self
pub fn validation_error<T: Into<String>>(message: T) -> Self
Create a validation error
Create an unauthorized error
Sourcepub fn internal_server_error<T: Into<String>>(message: T) -> Self
pub fn internal_server_error<T: Into<String>>(message: T) -> Self
Create an internal server error
Sourcepub fn payload_too_large<T: Into<String>>(_message: T) -> Self
pub fn payload_too_large<T: Into<String>>(_message: T) -> Self
Create a payload too large error
Sourcepub fn payload_too_large_with_sizes<T: Into<String>>(
_message: T,
size: usize,
limit: usize,
) -> Self
pub fn payload_too_large_with_sizes<T: Into<String>>( _message: T, size: usize, limit: usize, ) -> Self
Create a payload too large error with specific sizes
Sourcepub fn with_detail<T: Into<String>>(self, _detail: T) -> Self
pub fn with_detail<T: Into<String>>(self, _detail: T) -> Self
Add additional detail to error (for now, just returns self - future enhancement)
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Get the appropriate HTTP status code for this error
Sourcepub fn error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
Get error code for consistent API responses
Trait Implementations§
Source§impl Error for HttpError
impl Error for HttpError
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 From<ConfigError> for HttpError
impl From<ConfigError> for HttpError
Source§fn from(err: ConfigError) -> Self
fn from(err: ConfigError) -> Self
Converts to this type from the input type.
Source§impl From<ModelError> for HttpError
impl From<ModelError> for HttpError
Source§fn from(err: ModelError) -> Self
fn from(err: ModelError) -> Self
Converts to this type from the input type.
Source§impl IntoElifResponse for HttpError
impl IntoElifResponse for HttpError
fn into_elif_response(self) -> ElifResponse
Source§impl IntoResponse for HttpError
impl IntoResponse for HttpError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl Freeze for HttpError
impl RefUnwindSafe for HttpError
impl Send for HttpError
impl Sync for HttpError
impl Unpin for HttpError
impl UnwindSafe for HttpError
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more