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>(service: T) -> HttpError
pub fn service_resolution<T>(service: T) -> HttpError
Create a service resolution error
Sourcepub fn bad_request<T>(message: T) -> HttpError
pub fn bad_request<T>(message: T) -> HttpError
Create a bad request error
Sourcepub fn health_check<T>(reason: T) -> HttpError
pub fn health_check<T>(reason: T) -> HttpError
Create a health check error
Sourcepub fn database_error<T>(message: T) -> HttpError
pub fn database_error<T>(message: T) -> HttpError
Create a database error
Sourcepub fn validation_error<T>(message: T) -> HttpError
pub fn validation_error<T>(message: T) -> HttpError
Create a validation error
Create an unauthorized error
Sourcepub fn payload_too_large(size: usize, limit: usize) -> HttpError
pub fn payload_too_large(size: usize, limit: usize) -> HttpError
Create a payload too large error with specific sizes
Sourcepub fn with_detail<T>(self, _detail: T) -> HttpError
pub fn with_detail<T>(self, _detail: T) -> HttpError
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) -> HttpError
fn from(error: BootstrapError) -> HttpError
Converts to this type from the input type.
Source§impl From<ConfigError> for HttpError
impl From<ConfigError> for HttpError
Source§fn from(err: ConfigError) -> HttpError
fn from(err: ConfigError) -> HttpError
Converts to this type from the input type.
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<Body>
fn into_response(self) -> Response<Body>
Create a response.
Source§impl VersionedErrorExt for HttpError
impl VersionedErrorExt for HttpError
Source§fn versioned_bad_request(
version_info: &VersionInfo,
code: &str,
message: &str,
) -> Result<ElifResponse, HttpError>
fn versioned_bad_request( version_info: &VersionInfo, code: &str, message: &str, ) -> Result<ElifResponse, HttpError>
Create a version-aware bad request error
Source§fn versioned_not_found(
version_info: &VersionInfo,
resource: &str,
) -> Result<ElifResponse, HttpError>
fn versioned_not_found( version_info: &VersionInfo, resource: &str, ) -> Result<ElifResponse, HttpError>
Create a version-aware not found error
Source§fn versioned_validation_error(
version_info: &VersionInfo,
field_errors: HashMap<String, Vec<String>>,
) -> Result<ElifResponse, HttpError>
fn versioned_validation_error( version_info: &VersionInfo, field_errors: HashMap<String, Vec<String>>, ) -> Result<ElifResponse, HttpError>
Create a version-aware validation error
Source§fn versioned_internal_error(
version_info: &VersionInfo,
message: &str,
) -> Result<ElifResponse, HttpError>
fn versioned_internal_error( version_info: &VersionInfo, message: &str, ) -> Result<ElifResponse, HttpError>
Create a version-aware internal server error
Create a version-aware unauthorized error
Source§fn versioned_forbidden(
version_info: &VersionInfo,
message: &str,
) -> Result<ElifResponse, HttpError>
fn versioned_forbidden( version_info: &VersionInfo, message: &str, ) -> Result<ElifResponse, HttpError>
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
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