Skip to main content

PluginError

Enum PluginError 

Source
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:

VariantHTTPRetry?User-facing?Typical cause
Transient503yesnonetwork blip, upstream 5xx
RateLimited429yesyesupstream Retry-After / 429
Timeout504yesnorequest exceeded the deadline
InvalidInput400noyesbad request payload, validation failure
Unauthorized401noyesauth token missing/expired/insufficient
NotFound404noyesmodel / resource does not exist
Internal500nono (page on-call)misconfiguration, plugin bug

Variants§

§

Transient

Retryable transient failure (network blip, upstream 5xx, connection reset).

Fields

§message: String
§

RateLimited

Upstream rate-limited the request. Retry after the suggested duration if any.

Fields

§retry_after: Option<Duration>
§

Timeout

Request exceeded the deadline (or upstream timed out).

Fields

§

InvalidInput

Client-side error: malformed input, validation failure. Surface to user.

Fields

§message: String
§

Unauthorized

Authentication or authorization failure. Surface to user.

Fields

§message: String
§

NotFound

Resource not found (model, file, session, …). Surface to user.

Fields

§message: String
§

Internal

Operator-side error: misconfiguration, plugin bug, internal invariant violation. Hide details from end users; page on-call.

Fields

§message: String

Implementations§

Source§

impl PluginError

Source

pub fn transient(message: impl Into<String>) -> Self

Source

pub fn transient_with<E>(message: impl Into<String>, source: E) -> Self
where E: Error + Send + Sync + 'static,

Source

pub fn rate_limited(retry_after: Option<Duration>) -> Self

Source

pub fn rate_limited_with<E>(retry_after: Option<Duration>, source: E) -> Self
where E: Error + Send + Sync + 'static,

Source

pub fn timeout() -> Self

Source

pub fn timeout_with<E>(source: E) -> Self
where E: Error + Send + Sync + 'static,

Source

pub fn invalid_input(message: impl Into<String>) -> Self

Source

pub fn invalid_input_with<E>(message: impl Into<String>, source: E) -> Self
where E: Error + Send + Sync + 'static,

Source

pub fn unauthorized(message: impl Into<String>) -> Self

Source

pub fn unauthorized_with<E>(message: impl Into<String>, source: E) -> Self
where E: Error + Send + Sync + 'static,

Source

pub fn not_found(message: impl Into<String>) -> Self

Source

pub fn not_found_with<E>(message: impl Into<String>, source: E) -> Self
where E: Error + Send + Sync + 'static,

Source

pub fn internal(message: impl Into<String>) -> Self

Source

pub fn internal_with<E>(message: impl Into<String>, source: E) -> Self
where E: Error + Send + Sync + 'static,

Source

pub fn suggested_status(&self) -> u16

Suggested HTTP status code when this error surfaces to a client.

Source

pub fn is_retryable(&self) -> bool

Whether Chat Engine should retry the operation (with backoff).

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PluginError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for PluginError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.