pub enum BarnacleError {
RateLimitExceeded {
remaining: u32,
retry_after: u64,
limit: u32,
},
ApiKeyValidation {
reason: String,
},
ApiKeyMissing,
InvalidApiKey {
key_hint: String,
},
StoreError {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Redis {
message: String,
source: RedisError,
},
ConnectionPool {
message: String,
source: Box<dyn Error + Send + Sync>,
},
Configuration {
message: String,
},
JsonError {
message: String,
source: Error,
},
RequestParsing {
message: String,
},
Internal {
message: String,
},
Custom {
message: String,
status_code: Option<StatusCode>,
},
}
Expand description
Main error type for the Barnacle library
Variants§
RateLimitExceeded
Rate limit exceeded error
ApiKeyValidation
API key validation errors
ApiKeyMissing
Missing API key when required
InvalidApiKey
Invalid API key format or value
StoreError
Store/backend related errors
Redis
Redis-specific errors (when Redis feature is enabled)
ConnectionPool
Connection pool errors
Configuration
Configuration errors
JsonError
JSON serialization/deserialization errors
RequestParsing
Request parsing errors
Internal
Internal server errors
Custom
Custom errors for extending functionality
Implementations§
Source§impl BarnacleError
impl BarnacleError
Sourcepub fn rate_limit_exceeded(remaining: u32, retry_after: u64, limit: u32) -> Self
pub fn rate_limit_exceeded(remaining: u32, retry_after: u64, limit: u32) -> Self
Create a rate limit exceeded error
Sourcepub fn api_key_validation<S: Into<String>>(reason: S) -> Self
pub fn api_key_validation<S: Into<String>>(reason: S) -> Self
Create an API key validation error
Sourcepub fn invalid_api_key<S: Into<String>>(key: S) -> Self
pub fn invalid_api_key<S: Into<String>>(key: S) -> Self
Create an invalid API key error with a hint (truncated key for security)
Sourcepub fn store_error<S: Into<String>>(message: S) -> Self
pub fn store_error<S: Into<String>>(message: S) -> Self
Create a store error
Sourcepub fn store_error_with_source<S: Into<String>>(
message: S,
source: Box<dyn Error + Send + Sync>,
) -> Self
pub fn store_error_with_source<S: Into<String>>( message: S, source: Box<dyn Error + Send + Sync>, ) -> Self
Create a store error with source
Sourcepub fn redis_error<S: Into<String>>(message: S, source: RedisError) -> Self
pub fn redis_error<S: Into<String>>(message: S, source: RedisError) -> Self
Create a Redis error (only available with redis feature)
Sourcepub fn connection_pool_error<S: Into<String>>(
message: S,
source: Box<dyn Error + Send + Sync>,
) -> Self
pub fn connection_pool_error<S: Into<String>>( message: S, source: Box<dyn Error + Send + Sync>, ) -> Self
Create a connection pool error
Sourcepub fn configuration_error<S: Into<String>>(message: S) -> Self
pub fn configuration_error<S: Into<String>>(message: S) -> Self
Create a configuration error
Sourcepub fn json_error<S: Into<String>>(message: S, source: Error) -> Self
pub fn json_error<S: Into<String>>(message: S, source: Error) -> Self
Create a JSON error
Sourcepub fn request_parsing_error<S: Into<String>>(message: S) -> Self
pub fn request_parsing_error<S: Into<String>>(message: S) -> Self
Create a request parsing error
Sourcepub fn internal_error<S: Into<String>>(message: S) -> Self
pub fn internal_error<S: Into<String>>(message: S) -> Self
Create an internal server error
Sourcepub fn custom<S: Into<String>>(
message: S,
status_code: Option<StatusCode>,
) -> Self
pub fn custom<S: Into<String>>( message: S, status_code: Option<StatusCode>, ) -> Self
Create a custom error with optional status code
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Get the appropriate HTTP status code for this error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error should be retried
Sourcepub fn retry_after(&self) -> Option<u64>
pub fn retry_after(&self) -> Option<u64>
Get retry-after value in seconds if applicable
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Convert this error into a JSON representation
Sourcepub fn error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
Get a unique error code for this error type
Sourcepub fn error_type(&self) -> &'static str
pub fn error_type(&self) -> &'static str
Get the error type category
Source§impl BarnacleError
Extensions to provide additional error context
impl BarnacleError
Extensions to provide additional error context
Sourcepub fn with_context<S: Into<String>>(self, context: S) -> Self
pub fn with_context<S: Into<String>>(self, context: S) -> Self
Add additional context to an error
Trait Implementations§
Source§impl Debug for BarnacleError
impl Debug for BarnacleError
Source§impl Display for BarnacleError
impl Display for BarnacleError
Source§impl Error for BarnacleError
impl Error for BarnacleError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<Error> for BarnacleError
Convert from various error types into BarnacleError
impl From<Error> for BarnacleError
Convert from various error types into BarnacleError
Source§impl From<Error> for BarnacleError
impl From<Error> for BarnacleError
Source§impl From<PoolError<RedisError>> for BarnacleError
impl From<PoolError<RedisError>> for BarnacleError
Source§impl From<RedisError> for BarnacleError
impl From<RedisError> for BarnacleError
Source§fn from(err: RedisError) -> Self
fn from(err: RedisError) -> Self
Source§impl IntoResponse for BarnacleError
Implement IntoResponse for Axum integration
impl IntoResponse for BarnacleError
Implement IntoResponse for Axum integration