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>,
) -> Self
pub fn new( category: StreamErrorCategory, code: impl Into<String>, message: impl Into<String>, ) -> Self
Create a new stream error
Sourcepub fn rate_limit(
message: impl Into<String>,
retry_after_ms: Option<u64>,
) -> Self
pub fn rate_limit( message: impl Into<String>, retry_after_ms: Option<u64>, ) -> Self
Create a rate limit error
Sourcepub fn provider(provider: impl Into<String>, message: impl Into<String>) -> Self
pub fn provider(provider: impl Into<String>, message: impl Into<String>) -> Self
Create a provider error
Sourcepub fn with_provider(self, provider: impl Into<String>) -> Self
pub fn with_provider(self, provider: impl Into<String>) -> Self
Set provider
Sourcepub fn with_http_status(self, status: u16) -> Self
pub fn with_http_status(self, status: u16) -> Self
Set HTTP status
Sourcepub fn with_context(self, context: impl Into<String>) -> Self
pub fn with_context(self, context: impl Into<String>) -> Self
Set context
Sourcepub fn with_retry_after(self, ms: u64) -> Self
pub fn with_retry_after(self, ms: u64) -> Self
Set retry delay
Sourcepub fn non_retryable(self) -> Self
pub fn non_retryable(self) -> Self
Mark as non-retryable
Sourcepub fn from_http_response(provider: &str, status: u16, body: &str) -> Self
pub fn from_http_response(provider: &str, status: u16, body: &str) -> Self
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<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
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()
Auto Trait Implementations§
impl Freeze for StreamError
impl RefUnwindSafe for StreamError
impl Send for StreamError
impl Sync for StreamError
impl Unpin for StreamError
impl UnsafeUnpin 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> 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>
§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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§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.