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>,
pub detail: Option<ErrorDetail>,
}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.
detail: Option<ErrorDetail>Structured diagnostic for failures a consumer may want to route
rather than only display. Absent for the common case; see
ErrorDetail for what each variant carries and why.
Implementations§
Source§impl ErrorReport
impl ErrorReport
Sourcepub fn new(kind: ErrorKind, message: impl Into<String>) -> ErrorReport
pub fn new(kind: ErrorKind, message: impl Into<String>) -> ErrorReport
Build a report of kind with message and no other metadata.
Sourcepub fn with_retryable(self, retryable: bool) -> ErrorReport
pub fn with_retryable(self, retryable: bool) -> ErrorReport
Set retryable.
Sourcepub fn with_code(self, code: impl Into<String>) -> ErrorReport
pub fn with_code(self, code: impl Into<String>) -> ErrorReport
Set the machine code.
Sourcepub fn with_http_status(self, status: u16) -> ErrorReport
pub fn with_http_status(self, status: u16) -> ErrorReport
Set the HTTP status.
Sourcepub fn refused(self) -> ErrorReport
pub fn refused(self) -> ErrorReport
Mark the report as an intentional refusal.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> ErrorReport
pub fn with_request_id(self, request_id: impl Into<String>) -> ErrorReport
Attach the provider’s request id.
Sourcepub fn with_detail(self, detail: ErrorDetail) -> ErrorReport
pub fn with_detail(self, detail: ErrorDetail) -> ErrorReport
Attach a typed diagnostic.
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§fn clone(&self) -> ErrorReport
fn clone(&self) -> ErrorReport
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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<ErrorReport, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ErrorReport, <__D as Deserializer<'de>>::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) -> ErrorReport
fn from(error: &MemoryError) -> ErrorReport
Source§impl From<&ProviderError> for ErrorReport
impl From<&ProviderError> for ErrorReport
Source§fn from(error: &ProviderError) -> ErrorReport
fn from(error: &ProviderError) -> ErrorReport
Source§impl From<&ToolExecutionError> for ErrorReport
impl From<&ToolExecutionError> for ErrorReport
Source§fn from(error: &ToolExecutionError) -> ErrorReport
fn from(error: &ToolExecutionError) -> ErrorReport
Source§impl From<&VectorStoreError> for ErrorReport
impl From<&VectorStoreError> for ErrorReport
Source§fn from(error: &VectorStoreError) -> ErrorReport
fn from(error: &VectorStoreError) -> ErrorReport
Source§impl From<ErrorReport> for StreamingError
impl From<ErrorReport> for StreamingError
Source§fn from(source: ErrorReport) -> Self
fn from(source: ErrorReport) -> Self
Source§impl From<ErrorReport> for PromptError
impl From<ErrorReport> for PromptError
Source§fn from(source: ErrorReport) -> Self
fn from(source: ErrorReport) -> Self
Source§impl From<ErrorReport> for ScenarioError
Available on crate feature test-utils only.
impl From<ErrorReport> for ScenarioError
test-utils only.Source§fn from(source: ErrorReport) -> Self
fn from(source: ErrorReport) -> Self
Source§impl From<MemoryError> for ErrorReport
impl From<MemoryError> for ErrorReport
Source§fn from(error: MemoryError) -> ErrorReport
fn from(error: MemoryError) -> ErrorReport
Source§impl From<ProviderError> for ErrorReport
impl From<ProviderError> for ErrorReport
Source§fn from(error: ProviderError) -> ErrorReport
fn from(error: ProviderError) -> ErrorReport
Source§impl From<ToolExecutionError> for ErrorReport
impl From<ToolExecutionError> for ErrorReport
Source§fn from(error: ToolExecutionError) -> ErrorReport
fn from(error: ToolExecutionError) -> ErrorReport
Source§impl From<VectorStoreError> for ErrorReport
impl From<VectorStoreError> for ErrorReport
Source§fn from(error: VectorStoreError) -> ErrorReport
fn from(error: VectorStoreError) -> ErrorReport
Source§impl PartialEq for ErrorReport
impl PartialEq for ErrorReport
Source§impl Serialize for ErrorReport
impl Serialize for ErrorReport
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
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.