#[non_exhaustive]pub struct ModelInvokeError {
pub kind: ModelInvokeErrorKind,
pub message: String,
pub status: Option<u16>,
pub code: Option<String>,
pub retry_delay: Option<Duration>,
}Expand description
A model-invocation failure: a ModelInvokeErrorKind plus human-readable
detail (provider text included where available).
status and code repeat, as data, what the message says in words, so a
host can choose what to tell its user without parsing the message.
retry_delay carries a server-requested wait (an HTTP retry-after or
retry-after-ms header) when the transport filled one. The kernel does
not act on it; a caller-side retry policy decides whether to honor it.
Display prints the message alone; the kind is data, not prose.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: ModelInvokeErrorKindThe failure classification.
message: StringHuman-readable failure detail.
status: Option<u16>The HTTP status of a non-success response. None when the failure
did not come from one: a transport fault, a local check, or an error
reported inside a successful response.
code: Option<String>The provider’s own error code or type, such as rate_limit_error.
None when the provider named none or the value was not a short
identifier.
retry_delay: Option<Duration>Server-requested delay before another attempt, when the provider sent
one. None when no usable delay was disclosed.
Implementations§
Source§impl ModelInvokeError
impl ModelInvokeError
Sourcepub fn new(kind: ModelInvokeErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: ModelInvokeErrorKind, message: impl Into<String>) -> Self
Assembles an error from its kind and message, with no status, code or retry delay.
Sourcepub fn with_status(self, status: u16) -> Self
pub fn with_status(self, status: u16) -> Self
Records the HTTP status of the non-success response behind this error.
Sourcepub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
Records the provider’s error code or type. The caller passes only a short identifier; the kernel stores it as given.
Sourcepub fn with_retry_delay(self, delay: Duration) -> Self
pub fn with_retry_delay(self, delay: Duration) -> Self
Sets the server-requested retry delay. A retry policy may wait this long instead of using its own backoff.
Trait Implementations§
Source§impl Clone for ModelInvokeError
impl Clone for ModelInvokeError
Source§impl Debug for ModelInvokeError
impl Debug for ModelInvokeError
Source§impl Display for ModelInvokeError
impl Display for ModelInvokeError
Source§impl Error for ModelInvokeError
impl Error for ModelInvokeError
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()