#[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
NotFound
The source has no prompt by that name.
Fields
name: PromptNameThe 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: PromptNameThe name.
version: PromptVersionThe version that was pinned and is not there.
LabelNotFound
The prompt exists, but no version carries that label.
Fields
name: PromptNameThe name.
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: PromptNameThe 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
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
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.
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: PromptNameThe name that was asked for.
Implementations§
Source§impl PromptError
impl PromptError
Sourcepub const fn code(&self) -> &'static str
pub const fn code(&self) -> &'static str
A stable snake-case label, for a metric or a span attribute.
Sourcepub const fn is_transient(&self) -> bool
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
impl Clone for PromptError
Source§impl Debug for PromptError
impl Debug for PromptError
Source§impl Display for PromptError
impl Display for PromptError
impl Eq for PromptError
Source§impl Error for PromptError
impl Error for PromptError
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()
Source§impl PartialEq for PromptError
impl PartialEq for PromptError
impl StructuralPartialEq for PromptError
Auto Trait Implementations§
impl Freeze for PromptError
impl RefUnwindSafe for PromptError
impl Send for PromptError
impl Sync for PromptError
impl Unpin for PromptError
impl UnsafeUnpin for PromptError
impl UnwindSafe for PromptError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.