Skip to main content

PromptError

Enum PromptError 

Source
#[non_exhaustive]
pub enum PromptError { NotFound { name: PromptName, }, VersionNotFound { name: PromptName, version: PromptVersion, }, LabelNotFound { name: PromptName, label: String, }, Unauthorized, Forbidden { name: PromptName, }, RateLimited, Transport { code: &'static str, }, Malformed { code: &'static str, }, Unsupported { reason: &'static str, }, InconsistentReference { name: PromptName, }, }
Expand description

A prompt could not be loaded.

Two rules shape this family, and they are the two the provider layer follows.

Nothing here can print a secret. No variant has a field a credential, a response body or a prompt text could be put into: every field is a name, a label, a version or a short stable code. Display is therefore safe in a log line.

Every failure says whether it is worth trying again, through is_transient, because that is the difference between a cache that serves a held version for a moment and one that serves it forever.

The family grows as sources learn to distinguish more, so a downstream match needs a wildcard arm.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NotFound

The source has no prompt by that name.

Fields

§name: PromptName

The name that was asked for.

§

VersionNotFound

The prompt exists, but not at the version that was pinned.

A deployment that pins a version wants this to be loud: quietly serving a different version is exactly the failure pinning exists to prevent.

Fields

§name: PromptName

The name.

§version: PromptVersion

The version that was pinned and is not there.

§

LabelNotFound

The prompt exists, but no version carries that label.

Fields

§name: PromptName

The name.

§label: String

The label. A deployment label such as production, never user text.

§

Unauthorized

The credentials were rejected.

The credential itself is deliberately absent from every field, so this value cannot leak it however it is rendered.

§

Forbidden

The credentials are valid but not entitled to this project or prompt.

Fields

§name: PromptName

The name that was asked for.

§

RateLimited

The source asked for the request to be made again later.

§

Transport

The request never got a complete answer, or the answer was a server error.

Fields

§code: &'static str

A short stable code — "timeout", "connect", "status_503" — never a URL, a body or a header.

§

Malformed

The answer arrived and was not the shape the source expects.

Never carries the payload: a malformed answer from a registry is exactly the kind of thing that turns out to contain a token.

Fields

§code: &'static str

A short stable code naming what was wrong — "not_json", "missing_field", "version_not_a_number".

§

Unsupported

The source can reach the prompt but this adapter will not serve it.

Used where guessing would be worse than refusing: a chat-shaped prompt that would have to be flattened into one string to fit this trait, or an endpoint whose current API shape an adapter cannot verify.

Fields

§reason: &'static str

A short stable code naming what is unsupported.

§

InconsistentReference

The source returned a reference whose hash is not the hash of the text it returned, which breaks the obligation PromptSource states.

Fields

§name: PromptName

The name that was asked for.

Implementations§

Source§

impl PromptError

Source

pub const fn code(&self) -> &'static str

A stable snake-case label, for a metric or a span attribute.

Source

pub const fn is_transient(&self) -> bool

Returns true when the same request could plausibly succeed later without anybody changing anything.

A transport fault and a rate limit are transient. A missing name, a pinned version that does not exist, a rejected credential and a malformed answer are not: they need an edit somewhere before the answer changes.

Trait Implementations§

Source§

impl Clone for PromptError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PromptError

Source§

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

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

impl Display for PromptError

Source§

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

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

impl Eq for PromptError

Source§

impl Error for PromptError

1.30.0 · 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
Source§

impl PartialEq for PromptError

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PromptError

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.