pub struct ErrorReport {
pub kind: ErrorKind,
pub retryable: bool,
pub message: String,
pub code: Option<String>,
pub http_status: Option<u16>,
pub refusal: bool,
pub source_chain: Vec<String>,
pub request_id: Option<String>,
pub provider_response: Option<ProviderResponseError>,
}Expand description
A serde-able error crossing a wire boundary.
Field semantics:
retryableis the one policy signal; it is decided at conversion time from the source’s own classification (seeretryable_status).messageis the source’sDisplay;source_chainis theDisplayof eachsource()link, outermost first, excludingmessageitself.code,http_status,refusalare copied when the source had them.
Fields§
§kind: ErrorKindNormalized classification.
retryable: boolWhether the same operation may reasonably be retried.
message: StringHuman-readable description (the source’s Display).
code: Option<String>A provider- or tool-specific machine code, when one was reported:
for a provider’s reply, the transport’s own code when it gave one
apart from the body, else the code the body names
(provider_response::body_code).
http_status: Option<u16>The HTTP status, when the failure had one.
refusal: boolThe failure was an intentional refusal rather than a fault.
source_chain: Vec<String>Display of each source() link, outermost first.
request_id: Option<String>The provider’s request id, when the failure had a response that carried one.
provider_response: Option<ProviderResponseError>Preserved provider failure response, including available status, body, headers, and request ID.
Implementations§
Source§impl ErrorReport
impl ErrorReport
Sourcepub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
Build a report of kind with message and no other metadata.
Sourcepub fn with_retryable(self, retryable: bool) -> Self
pub fn with_retryable(self, retryable: bool) -> Self
Set retryable.
Sourcepub fn with_http_status(self, status: u16) -> Self
pub fn with_http_status(self, status: u16) -> Self
Set the HTTP status.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Attach the provider’s request id.
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Whether the same operation may reasonably be retried.
Source§impl ErrorReport
impl ErrorReport
Sourcepub fn provider_response_body(&self) -> Option<&str>
pub fn provider_response_body(&self) -> Option<&str>
The provider response body preserved on this report, if any.
Sourcepub fn provider_response_json(&self) -> Result<Option<Value>, Error>
pub fn provider_response_json(&self) -> Result<Option<Value>, Error>
The preserved provider response body parsed as JSON, when present.
Sourcepub fn provider_response_headers(&self) -> Option<&HeaderMap>
pub fn provider_response_headers(&self) -> Option<&HeaderMap>
The preserved provider response headers, if any.
Sourcepub fn provider_response_status(&self) -> Option<StatusCode>
pub fn provider_response_status(&self) -> Option<StatusCode>
The HTTP status this report carries, as a status code.
Sourcepub fn provider_request_id(&self) -> Option<&str>
pub fn provider_request_id(&self) -> Option<&str>
The provider’s transport request id, if the failure carried one.
Trait Implementations§
Source§impl Clone for ErrorReport
impl Clone for ErrorReport
Source§impl Debug for ErrorReport
impl Debug for ErrorReport
Source§impl<'de> Deserialize<'de> for ErrorReport
impl<'de> Deserialize<'de> for ErrorReport
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 ErrorReport
impl Display for ErrorReport
impl Eq for ErrorReport
Source§impl Error for ErrorReport
impl Error for ErrorReport
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 From<&MemoryError> for ErrorReport
impl From<&MemoryError> for ErrorReport
Source§fn from(error: &MemoryError) -> Self
fn from(error: &MemoryError) -> Self
Source§impl From<&ProviderError> for ErrorReport
impl From<&ProviderError> for ErrorReport
Source§fn from(error: &ProviderError) -> Self
fn from(error: &ProviderError) -> Self
Source§impl From<&ToolExecutionError> for ErrorReport
impl From<&ToolExecutionError> for ErrorReport
Source§fn from(error: &ToolExecutionError) -> Self
fn from(error: &ToolExecutionError) -> Self
Source§impl From<&VectorStoreError> for ErrorReport
impl From<&VectorStoreError> for ErrorReport
Source§fn from(error: &VectorStoreError) -> Self
fn from(error: &VectorStoreError) -> Self
Source§impl From<ErrorReport> for ToolExecutionError
Rebuilds a tool failure from a dispatch report.
impl From<ErrorReport> for ToolExecutionError
Rebuilds a tool failure from a dispatch report.
An ErrorKind::Tool report keeps its tool kind; other kinds map to the
closest ToolErrorKind. Retryability, code, HTTP status, and refusal are
copied, the message is model-visible, and the report is the source().
Source§fn from(report: ErrorReport) -> Self
fn from(report: ErrorReport) -> Self
Source§impl From<MemoryError> for ErrorReport
impl From<MemoryError> for ErrorReport
Source§fn from(error: MemoryError) -> Self
fn from(error: MemoryError) -> Self
Source§impl From<ProviderError> for ErrorReport
impl From<ProviderError> for ErrorReport
Source§fn from(error: ProviderError) -> Self
fn from(error: ProviderError) -> Self
Source§impl From<ToolExecutionError> for ErrorReport
impl From<ToolExecutionError> for ErrorReport
Source§fn from(error: ToolExecutionError) -> Self
fn from(error: ToolExecutionError) -> Self
Source§impl From<VectorStoreError> for ErrorReport
impl From<VectorStoreError> for ErrorReport
Source§fn from(error: VectorStoreError) -> Self
fn from(error: VectorStoreError) -> Self
Source§impl PartialEq for ErrorReport
impl PartialEq for ErrorReport
Source§impl Serialize for ErrorReport
impl Serialize for ErrorReport
impl StructuralPartialEq for ErrorReport
Auto Trait Implementations§
impl Freeze for ErrorReport
impl RefUnwindSafe for ErrorReport
impl Send for ErrorReport
impl Sync for ErrorReport
impl Unpin for ErrorReport
impl UnsafeUnpin for ErrorReport
impl UnwindSafe for ErrorReport
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.