pub struct WireError {
pub kind: WireErrorKind,
pub message: String,
pub provider: Option<ProviderKind>,
pub retryable: bool,
}Expand description
A serializable projection of the crate’s Error.
Error cannot cross a wire: it wraps reqwest::Error and
serde_json::Error, neither of which is Serialize. WireError keeps the
parts a remote client can act on — the category, a human-readable message,
the provider, and whether a retry might help — and drops the rest.
The conversion is deliberately one-way. Rebuilding a reqwest::Error from
JSON is not possible, so a client matches on kind
rather than on the original error variant.
§Examples
use rai_sdk::{Error, ProviderKind};
use rai_sdk::wire::{WireError, WireErrorKind};
let error = Error::RateLimit {
provider: ProviderKind::OpenAI,
message: "slow down".to_string(),
};
let wire = WireError::from(&error);
assert_eq!(wire.kind, WireErrorKind::RateLimit);
assert_eq!(wire.provider, Some(ProviderKind::OpenAI));
assert!(wire.retryable);Fields§
§kind: WireErrorKindError category, mirroring Error::kind_str.
message: StringHuman-readable description, from the original error’s Display.
provider: Option<ProviderKind>Provider the failure came from, when the error names one.
retryable: boolWhether retrying the request might succeed, from Error::is_retryable.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for WireError
impl<'de> Deserialize<'de> for WireError
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for WireError
Source§impl Error for WireError
impl Error for WireError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
impl StructuralPartialEq for WireError
Auto Trait Implementations§
impl Freeze for WireError
impl RefUnwindSafe for WireError
impl Send for WireError
impl Sync for WireError
impl Unpin for WireError
impl UnsafeUnpin for WireError
impl UnwindSafe for WireError
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
Mutably borrows from an owned value. Read more
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.