pub struct ModelError { /* private fields */ }Expand description
Public-safe typed failure returned by a model adapter.
Optional usage is the last complete normalized cumulative snapshot known for the failed attempt. Missing usage means unknown and must never be interpreted as zero. Stream consumers discard partial output as a completed response and separately account for any reported usage.
Implementations§
Source§impl ModelError
impl ModelError
Sourcepub fn new(
failure: Failure,
phase: ModelErrorPhase,
provenance: ModelErrorProvenance,
usage: Option<ModelUsage>,
) -> Self
pub fn new( failure: Failure, phase: ModelErrorPhase, provenance: ModelErrorProvenance, usage: Option<ModelUsage>, ) -> Self
Constructs a model failure from validated public-safe components.
Sourcepub fn validate_for(
&self,
context: &ModelContext,
descriptor: &ModelDescriptor,
request: &ModelRequest,
) -> Result<(), ModelErrorValidationError>
pub fn validate_for( &self, context: &ModelContext, descriptor: &ModelDescriptor, request: &ModelRequest, ) -> Result<(), ModelErrorValidationError>
Revalidates attempt, model, response-mode, and usage bindings.
§Errors
Returns ModelErrorValidationError when this failure does not belong
to the exact context/descriptor/request snapshot or its reported usage
exceeds the request ceilings.
Sourcepub fn validate_for_attempt(
&self,
attempt_id: AttemptId,
descriptor: &ModelDescriptor,
request: &ModelRequest,
) -> Result<(), ModelErrorValidationError>
pub fn validate_for_attempt( &self, attempt_id: AttemptId, descriptor: &ModelDescriptor, request: &ModelRequest, ) -> Result<(), ModelErrorValidationError>
Revalidates this failure against a durable attempt identity and exact descriptor/request snapshot.
This is the persistence-safe counterpart to Self::validate_for: a
recovered ledger has no process-local monotonic clock or cancellation
handle, but it must still reject attempt, model, delivery-mode, and usage
substitution before using the failure as retry evidence.
§Errors
Returns ModelErrorValidationError for any binding mismatch.
Sourcepub fn into_failure(self) -> Failure
pub fn into_failure(self) -> Failure
Consumes this value and returns the common failure occurrence.
Sourcepub const fn phase(&self) -> ModelErrorPhase
pub const fn phase(&self) -> ModelErrorPhase
Returns the stage at which the attempt failed.
Sourcepub const fn provenance(&self) -> &ModelErrorProvenance
pub const fn provenance(&self) -> &ModelErrorProvenance
Returns attempt and provider correlation evidence.
Sourcepub const fn usage(&self) -> Option<&ModelUsage>
pub const fn usage(&self) -> Option<&ModelUsage>
Returns the last complete normalized usage snapshot, when known.
Trait Implementations§
Source§impl Clone for ModelError
impl Clone for ModelError
Source§impl Debug for ModelError
impl Debug for ModelError
Source§impl<'de> Deserialize<'de> for ModelError
impl<'de> Deserialize<'de> for ModelError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ModelError
impl Display for ModelError
Source§impl Error for ModelError
impl Error for ModelError
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl JsonSchema for ModelError
impl JsonSchema for ModelError
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more