#[non_exhaustive]pub struct ItemError {
pub code: String,
pub class: ErrorClass,
pub message: String,
pub retry_after_ms: Option<u64>,
pub detail: Option<ItemErrorDetail>,
}Expand description
An item’s error in a batch reply: {code, class, message, retry_after_ms?, detail?}.
Non-exhaustive so later optional members are additive: use
ItemError::new or ItemError::for_code and the with_* setters,
or decode one.
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.code: StringA per-item code this crate lists; any other value decodes as a plain string.
class: ErrorClass§message: String§retry_after_ms: Option<u64>When the provider said how long to wait.
detail: Option<ItemErrorDetail>Present only on codes that define one (ANSWER_TOO_LARGE).
Implementations§
Source§impl ItemError
impl ItemError
pub fn new( code: impl Into<String>, class: ErrorClass, message: impl Into<String>, ) -> Self
Sourcepub fn for_code(code: &str, message: impl Into<String>) -> Self
pub fn for_code(code: &str, message: impl Into<String>) -> Self
An error with the class the vocabulary gives code; a code this
crate does not list gets ErrorClass::Permanent.
Sourcepub fn answer_too_large(field: impl Into<String>, limit: u64, size: u64) -> Self
pub fn answer_too_large(field: impl Into<String>, limit: u64, size: u64) -> Self
answer_too_large for the answer to field, size bytes against a
bound of limit.
pub fn with_retry_after_ms(self, retry_after_ms: u64) -> Self
pub fn with_detail(self, detail: ItemErrorDetail) -> Self
Sourcepub fn is_retried_on_resend(&self) -> bool
pub fn is_retried_on_resend(&self) -> bool
Whether a re-send of the batch asks the provider again for an item whose stored outcome is this error. A stored transient error is retried and its new outcome replaces it; a stored permanent one (and one of an unknown class) is returned as stored, with no provider call.
Sourcepub fn is_stored(&self) -> bool
pub fn is_stored(&self) -> bool
Whether a runner records this error as the item’s outcome. Every
error is, except the ones that say nothing about the item:
auth_failed, model_unavailable, account_limit_exhausted and
account_not_entitled. The item stays unanswered, and a re-send
(after a re-login, a catalog fix, the allocation’s reset or an
operator’s fix) asks the provider again.
This answers for an item the provider actually answered with this
error. A rate_limited item is stored like any transient error; the
items after it that a rate limit stopped the call from sending carry
rate_limited in the reply but are never recorded, which is the
runner’s rule for unsent items and not something this code decides.
Sourcepub fn stops_the_call(&self) -> bool
pub fn stops_the_call(&self) -> bool
Whether this error, once an item ends with it, stops the call: no
further item is sent to the provider in that call, and every item
the call leaves unanswered carries the same code. True for the
batch-level codes and rate_limited.