pub enum PluginError {
Transient {
message: String,
source: Option<BoxError>,
},
RateLimited {
retry_after: Option<Duration>,
source: Option<BoxError>,
},
Timeout {
source: Option<BoxError>,
},
InvalidInput {
message: String,
source: Option<BoxError>,
},
Unauthorized {
message: String,
source: Option<BoxError>,
},
NotFound {
message: String,
source: Option<BoxError>,
},
Internal {
message: String,
source: Option<BoxError>,
},
}Expand description
Errors returned by ChatEngineBackendPlugin methods.
Each variant has a clear contract for how Chat Engine reacts when it sees
it (HTTP status to surface, retry policy, whether details may be shown to
the end user). Use the constructors (PluginError::transient(...),
PluginError::invalid_input_with(..., source) …) to build values; they
preserve the original error chain via the #[source] field.
Routing matrix:
| Variant | HTTP | Retry? | User-facing? | Typical cause |
|---|---|---|---|---|
Transient | 503 | yes | no | network blip, upstream 5xx |
RateLimited | 429 | yes | yes | upstream Retry-After / 429 |
Timeout | 504 | yes | no | request exceeded the deadline |
InvalidInput | 400 | no | yes | bad request payload, validation failure |
Unauthorized | 401 | no | yes | auth token missing/expired/insufficient |
NotFound | 404 | no | yes | model / resource does not exist |
Internal | 500 | no | no (page on-call) | misconfiguration, plugin bug |
Variants§
Transient
Retryable transient failure (network blip, upstream 5xx, connection reset).
RateLimited
Upstream rate-limited the request. Retry after the suggested duration if any.
Timeout
Request exceeded the deadline (or upstream timed out).
InvalidInput
Client-side error: malformed input, validation failure. Surface to user.
Authentication or authorization failure. Surface to user.
Fields
NotFound
Resource not found (model, file, session, …). Surface to user.
Internal
Operator-side error: misconfiguration, plugin bug, internal invariant violation. Hide details from end users; page on-call.
Implementations§
Source§impl PluginError
impl PluginError
pub fn transient(message: impl Into<String>) -> Self
pub fn transient_with<E>(message: impl Into<String>, source: E) -> Self
pub fn rate_limited(retry_after: Option<Duration>) -> Self
pub fn rate_limited_with<E>(retry_after: Option<Duration>, source: E) -> Self
pub fn timeout() -> Self
pub fn timeout_with<E>(source: E) -> Self
pub fn invalid_input(message: impl Into<String>) -> Self
pub fn invalid_input_with<E>(message: impl Into<String>, source: E) -> Self
pub fn not_found(message: impl Into<String>) -> Self
pub fn not_found_with<E>(message: impl Into<String>, source: E) -> Self
pub fn internal(message: impl Into<String>) -> Self
pub fn internal_with<E>(message: impl Into<String>, source: E) -> Self
Sourcepub fn suggested_status(&self) -> u16
pub fn suggested_status(&self) -> u16
Suggested HTTP status code when this error surfaces to a client.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether Chat Engine should retry the operation (with backoff).
Sourcepub fn is_user_facing(&self) -> bool
pub fn is_user_facing(&self) -> bool
True if the error’s message is safe to surface to the end user.
User-actionable errors (InvalidInput, Unauthorized, NotFound,
RateLimited) describe user mistakes; the rest may leak operator
details and must be replaced by a generic message at the boundary.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Retry-After hint if the variant carries one (currently only
RateLimited). Returns None for variants without an explicit hint.
Trait Implementations§
Source§impl Debug for PluginError
impl Debug for PluginError
Source§impl Display for PluginError
impl Display for PluginError
Source§impl Error for PluginError
impl Error for PluginError
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()