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 payload_too_large(size: usize, limit: usize) -> Self
pub fn payload_too_large(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 error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
Get error code for consistent API responses
Source§impl HttpError
impl HttpError
Sourcepub fn status_code(&self) -> ElifStatusCode
pub fn status_code(&self) -> ElifStatusCode
Get the appropriate HTTP status code for this error
Sourcepub fn error_hint(&self) -> Option<&'static str>
pub fn error_hint(&self) -> Option<&'static str>
Get error hint for user guidance
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 ErrorAssertions for HttpError
impl ErrorAssertions for HttpError
fn assert_error_code(&self, expected: &str)
fn assert_status_code(&self, expected: ElifStatusCode)
Source§impl From<BootstrapError> for HttpError
impl From<BootstrapError> for HttpError
Source§fn from(error: BootstrapError) -> Self
fn from(error: BootstrapError) -> Self
Converts to this type from the input type.
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<HttpError> for BootstrapError
impl From<HttpError> for BootstrapError
Source§impl IntoElifResponse for HttpError
impl IntoElifResponse for HttpError
fn into_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.
Source§impl VersionedErrorExt for HttpError
impl VersionedErrorExt for HttpError
Source§fn versioned_bad_request(
version_info: &VersionInfo,
code: &str,
message: &str,
) -> HttpResult<ElifResponse>
fn versioned_bad_request( version_info: &VersionInfo, code: &str, message: &str, ) -> HttpResult<ElifResponse>
Create a version-aware bad request error
Source§fn versioned_not_found(
version_info: &VersionInfo,
resource: &str,
) -> HttpResult<ElifResponse>
fn versioned_not_found( version_info: &VersionInfo, resource: &str, ) -> HttpResult<ElifResponse>
Create a version-aware not found error
Source§fn versioned_validation_error(
version_info: &VersionInfo,
field_errors: HashMap<String, Vec<String>>,
) -> HttpResult<ElifResponse>
fn versioned_validation_error( version_info: &VersionInfo, field_errors: HashMap<String, Vec<String>>, ) -> HttpResult<ElifResponse>
Create a version-aware validation error
Source§fn versioned_internal_error(
version_info: &VersionInfo,
message: &str,
) -> HttpResult<ElifResponse>
fn versioned_internal_error( version_info: &VersionInfo, message: &str, ) -> HttpResult<ElifResponse>
Create a version-aware internal server error
Create a version-aware unauthorized error
Source§fn versioned_forbidden(
version_info: &VersionInfo,
message: &str,
) -> HttpResult<ElifResponse>
fn versioned_forbidden( version_info: &VersionInfo, message: &str, ) -> HttpResult<ElifResponse>
Create a version-aware forbidden error
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