pub struct StreamError {
pub category: StreamErrorCategory,
pub code: String,
pub message: String,
pub provider: Option<String>,
pub http_status: Option<u16>,
pub retryable: bool,
pub retry_after_ms: Option<u64>,
pub context: Option<String>,
}Expand description
Streaming error with rich context
Fields§
§category: StreamErrorCategoryError category
code: StringError code (provider-specific or internal)
message: StringHuman-readable message
provider: Option<String>Provider name if applicable
http_status: Option<u16>HTTP status code if applicable
retryable: boolWhether this error is retryable
retry_after_ms: Option<u64>Suggested retry delay in milliseconds
context: Option<String>Additional context for debugging
Implementations§
Source§impl StreamError
impl StreamError
Sourcepub fn new(
category: StreamErrorCategory,
code: impl Into<String>,
message: impl Into<String>,
) -> StreamError
pub fn new( category: StreamErrorCategory, code: impl Into<String>, message: impl Into<String>, ) -> StreamError
Create a new stream error
Sourcepub fn network(message: impl Into<String>) -> StreamError
pub fn network(message: impl Into<String>) -> StreamError
Create a network error
Sourcepub fn timeout(message: impl Into<String>) -> StreamError
pub fn timeout(message: impl Into<String>) -> StreamError
Create a timeout error
Sourcepub fn auth(message: impl Into<String>) -> StreamError
pub fn auth(message: impl Into<String>) -> StreamError
Create an auth error
Sourcepub fn rate_limit(
message: impl Into<String>,
retry_after_ms: Option<u64>,
) -> StreamError
pub fn rate_limit( message: impl Into<String>, retry_after_ms: Option<u64>, ) -> StreamError
Create a rate limit error
Sourcepub fn provider(
provider: impl Into<String>,
message: impl Into<String>,
) -> StreamError
pub fn provider( provider: impl Into<String>, message: impl Into<String>, ) -> StreamError
Create a provider error
Sourcepub fn format(message: impl Into<String>) -> StreamError
pub fn format(message: impl Into<String>) -> StreamError
Create a format error
Sourcepub fn resource(message: impl Into<String>) -> StreamError
pub fn resource(message: impl Into<String>) -> StreamError
Create a resource exhaustion error
Sourcepub fn internal(message: impl Into<String>) -> StreamError
pub fn internal(message: impl Into<String>) -> StreamError
Create an internal error
Sourcepub fn cancelled() -> StreamError
pub fn cancelled() -> StreamError
Create a cancellation error
Sourcepub fn with_provider(self, provider: impl Into<String>) -> StreamError
pub fn with_provider(self, provider: impl Into<String>) -> StreamError
Set provider
Sourcepub fn with_http_status(self, status: u16) -> StreamError
pub fn with_http_status(self, status: u16) -> StreamError
Set HTTP status
Sourcepub fn with_context(self, context: impl Into<String>) -> StreamError
pub fn with_context(self, context: impl Into<String>) -> StreamError
Set context
Sourcepub fn with_retry_after(self, ms: u64) -> StreamError
pub fn with_retry_after(self, ms: u64) -> StreamError
Set retry delay
Sourcepub fn non_retryable(self) -> StreamError
pub fn non_retryable(self) -> StreamError
Mark as non-retryable
Sourcepub fn from_http_response(
provider: &str,
status: u16,
body: &str,
) -> StreamError
pub fn from_http_response( provider: &str, status: u16, body: &str, ) -> StreamError
Parse error from HTTP response
Trait Implementations§
Source§impl Clone for StreamError
impl Clone for StreamError
Source§fn clone(&self) -> StreamError
fn clone(&self) -> StreamError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StreamError
impl Debug for StreamError
Source§impl<'de> Deserialize<'de> for StreamError
impl<'de> Deserialize<'de> for StreamError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StreamError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StreamError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for StreamError
impl Display for StreamError
Source§impl Error for StreamError
impl Error for StreamError
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()
Source§impl Serialize for StreamError
impl Serialize for StreamError
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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for StreamError
impl RefUnwindSafe for StreamError
impl Send for StreamError
impl Sync for StreamError
impl Unpin for StreamError
impl UnwindSafe for StreamError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.