pub enum PulseError {
Auth {
path: String,
body: Option<Value>,
},
NotFound {
path: String,
body: Option<Value>,
},
Validation {
path: String,
body: Option<Value>,
},
RateLimit {
path: String,
body: Option<Value>,
retry_after_seconds: Option<u32>,
},
Api {
status: u16,
path: String,
body: Option<Value>,
},
Transport(Error),
Json(Error),
NoToken {
path: String,
},
InvalidConfig(String),
}Expand description
The single error type returned by every PulseClient method.
Variants§
Auth
401 — invalid / missing / expired JWT.
NotFound
404 — the resource does not exist.
Validation
400 — the request body is malformed.
RateLimit
429 — per-user or per-IP rate limit hit. Carries the server’s advised
wait time, parsed from either the retryAfterSeconds JSON field or the
Retry-After HTTP header. None means the server gave no hint.
Api
Any other non-2xx status code (5xx, unexpected 4xx).
Transport(Error)
The HTTP transport itself failed (connection refused, timeout, DNS, TLS handshake, etc.). Wraps the underlying reqwest error.
Json(Error)
JSON serialisation / deserialisation failure. The wire format the server returned doesn’t match what the client expected.
NoToken
The caller invoked an authenticated endpoint without setting a token
first. Surfaces before any network call, so it has no body.
InvalidConfig(String)
The supplied configuration is invalid (e.g. empty base_url).
Implementations§
Source§impl PulseError
impl PulseError
pub fn is_auth_error(&self) -> bool
pub fn is_not_found(&self) -> bool
pub fn is_validation_error(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
HTTP status code, if the error carries one. None for transport /
JSON / no-token / config errors.
pub fn path(&self) -> Option<&str>
Trait Implementations§
Source§impl Debug for PulseError
impl Debug for PulseError
Source§impl Display for PulseError
impl Display for PulseError
Source§impl Error for PulseError
impl Error for PulseError
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
use the Display impl or to_string()