pub enum StandardError {
BadRequest {
message: String,
},
ValidationFailed {
errors: Vec<ValidationError>,
},
Unauthenticated,
Forbidden {
reason: String,
},
NotFound,
Conflict {
message: String,
},
UnprocessableEntity {
message: String,
},
RateLimited {
retry_after_seconds: u32,
},
Internal,
ServiceUnavailable {
retry_after_seconds: u32,
},
Timeout,
}Expand description
Built-in standard errors. Procedures may use these directly or wrap them.
This is a curated set of “common” RPC errors that map cleanly onto well-known HTTP status codes. The full taxonomy is:
| Variant | Code | HTTP |
|---|---|---|
BadRequest | bad_request | 400 |
ValidationFailed | validation_error | 400 |
Unauthenticated | unauthenticated | 401 |
Forbidden | forbidden | 403 |
NotFound | not_found | 404 |
Conflict | conflict | 409 |
UnprocessableEntity | unprocessable_entity | 422 |
RateLimited | rate_limited | 429 |
Internal | internal | 500 |
ServiceUnavailable | service_unavailable | 503 |
Timeout | timeout | 504 |
Note: ValidationFailed carries a list of ValidationError entries and
is emitted by the server router when input validation rejects a request
before the procedure runs. Its discriminant is validation_error (not
validation_failed) to match the wire contract.
§Design principle
StandardError is intentionally narrow: it covers the cross-cutting concerns
every RPC stack tends to hit (auth, rate limiting, transport-shaped failures)
and nothing else. Anything domain-specific — business-rule violations,
per-procedure failure modes, structured validation results — should be its
own error enum with #[derive(taut_rpc::TautError)]. Reaching for
StandardError to model domain errors collapses meaningful distinctions
into a single bucket and is an anti-pattern.
Per SPEC §8 the unauthenticated discriminant is reserved.
Variants§
BadRequest
400 — Malformed or syntactically invalid request.
ValidationFailed
400 — Server-side input validation rejected the request before the
procedure ran. Carries the per-field failures that the validator
collected. Serializes with the validation_error discriminant.
Fields
errors: Vec<ValidationError>Per-field validation failures collected by the validator.
Unauthenticated
401 — Caller is not authenticated.
Forbidden
403 — Caller is authenticated but not permitted.
NotFound
404 — Target resource does not exist.
Conflict
409 — State conflict (e.g. unique-key violation, optimistic-lock failure).
UnprocessableEntity
422 — Request was syntactically valid but failed semantic validation.
RateLimited
429 — Caller is being rate limited.
Internal
500 — Unexpected server-side failure.
503 — Service is temporarily unavailable (graceful degradation, deploys, etc.).
Timeout
504 — Upstream or internal operation timed out.
Trait Implementations§
Source§impl Clone for StandardError
impl Clone for StandardError
Source§fn clone(&self) -> StandardError
fn clone(&self) -> StandardError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StandardError
impl Debug for StandardError
Source§impl Display for StandardError
impl Display for StandardError
Source§impl Error for StandardError
impl Error for StandardError
1.30.0 · 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()