pub enum WiseGateError {
Show 15 variants
InvalidIp(String),
ConfigError(String),
ProxyError(String),
RateLimitExceeded(String),
IpBlocked(String),
PatternBlocked(String),
MethodBlocked(String),
AuthenticationRequired,
InvalidCredentials,
UpstreamConnectionFailed(String),
UpstreamTimeout(String),
BodyTooLarge {
size: usize,
max: usize,
},
BodyReadError(String),
HttpClientError(Error),
InvalidHeader(String),
}Expand description
Unified error type for WiseGate operations.
This enum covers all error cases that can occur during request processing, configuration, and proxying operations.
§Example
use wisegate_core::error::{WiseGateError, Result};
fn validate_ip(ip: &str) -> Result<()> {
if ip.is_empty() {
return Err(WiseGateError::InvalidIp("IP address cannot be empty".into()));
}
Ok(())
}Variants§
InvalidIp(String)
Invalid IP address format or value.
ConfigError(String)
Configuration error (missing or invalid values).
ProxyError(String)
Error during request proxying.
RateLimitExceeded(String)
Rate limit exceeded for a client.
IpBlocked(String)
Request blocked by IP filter.
PatternBlocked(String)
Request blocked by URL pattern filter.
MethodBlocked(String)
Request blocked by HTTP method filter.
AuthenticationRequired
Authentication required but not provided.
InvalidCredentials
Invalid authentication credentials.
UpstreamConnectionFailed(String)
Upstream connection failed.
UpstreamTimeout(String)
Upstream request timed out.
BodyTooLarge
Request body too large.
BodyReadError(String)
Failed to read request or response body.
HttpClientError(Error)
HTTP client error (from reqwest).
InvalidHeader(String)
Invalid HTTP header value.
Implementations§
Source§impl WiseGateError
impl WiseGateError
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Returns the appropriate HTTP status code for this error.
§Returns
The HTTP status code that should be returned to the client.
Sourcepub fn user_message(&self) -> &str
pub fn user_message(&self) -> &str
Returns a user-friendly error message suitable for HTTP responses.
This method returns a sanitized message that doesn’t expose internal details to clients.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns true if this error should be logged at error level.
Some errors (like rate limiting) are expected and should only be logged at debug/info level.
Trait Implementations§
Source§impl Debug for WiseGateError
impl Debug for WiseGateError
Source§impl Display for WiseGateError
impl Display for WiseGateError
Source§impl Error for WiseGateError
impl Error for WiseGateError
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
Auto Trait Implementations§
impl Freeze for WiseGateError
impl !RefUnwindSafe for WiseGateError
impl Send for WiseGateError
impl Sync for WiseGateError
impl Unpin for WiseGateError
impl !UnwindSafe for WiseGateError
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
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.