pub struct Error { /* private fields */ }Expand description
Opaque canonical RocketMQ error.
Identity and policy are owned by a reviewed catalog descriptor. Each value retains typed context, at most one direct typed source, its first-promotion caller location, and an optional catalog-controlled backtrace behind one boxed pointer.
Error is intentionally not cloneable. Use SharedError when multiple
owners must observe the same error instance.
use rocketmq_error::{Error, CORE_INTERNAL_FAILURE};
let error = Error::new(&CORE_INTERNAL_FAILURE);
let _copy = error.clone();Implementations§
Source§impl Error
impl Error
Sourcepub fn new(descriptor: &'static ErrorDescriptor) -> Self
pub fn new(descriptor: &'static ErrorDescriptor) -> Self
Creates a source-free canonical error from a catalog descriptor.
Sourcepub fn caused_by(
descriptor: &'static ErrorDescriptor,
source: impl StdError + Send + Sync + 'static,
) -> Self
pub fn caused_by( descriptor: &'static ErrorDescriptor, source: impl StdError + Send + Sync + 'static, ) -> Self
Creates a canonical error while retaining the direct typed source.
Sourcepub fn with_context(self, context: ErrorContext) -> Self
pub fn with_context(self, context: ErrorContext) -> Self
Replaces the typed context without changing source or provenance.
Sourcepub fn with_source(self, source: impl StdError + Send + Sync + 'static) -> Self
pub fn with_source(self, source: impl StdError + Send + Sync + 'static) -> Self
Replaces the direct typed source without changing context or provenance.
Sourcepub fn with_boxed_source(
self,
source: Box<dyn StdError + Send + Sync + 'static>,
) -> Self
pub fn with_boxed_source( self, source: Box<dyn StdError + Send + Sync + 'static>, ) -> Self
Replaces the direct boxed source without adding another causal layer.
Sourcepub const fn descriptor(&self) -> &'static ErrorDescriptor
pub const fn descriptor(&self) -> &'static ErrorDescriptor
Returns the catalog descriptor that owns identity and policy.
Sourcepub const fn class(&self) -> ErrorClass
pub const fn class(&self) -> ErrorClass
Returns the broad catalog-owned class.
Sourcepub const fn condition(&self) -> CanonicalCondition
pub const fn condition(&self) -> CanonicalCondition
Returns the protocol-independent canonical condition.
Sourcepub const fn fault(&self) -> FaultAttribution
pub const fn fault(&self) -> FaultAttribution
Returns the catalog-owned fault attribution.
Sourcepub const fn component(&self) -> ComponentId
pub const fn component(&self) -> ComponentId
Returns the catalog component that owns this identity.
Sourcepub const fn severity(&self) -> ErrorSeverity
pub const fn severity(&self) -> ErrorSeverity
Returns the catalog-owned severity.
Sourcepub const fn recovery_hint(&self) -> RecoveryHint
pub const fn recovery_hint(&self) -> RecoveryHint
Returns the catalog-owned recovery hint.
Sourcepub const fn backtrace_policy(&self) -> BacktracePolicy
pub const fn backtrace_policy(&self) -> BacktracePolicy
Returns the catalog-controlled backtrace policy.
Sourcepub const fn projection(&self) -> ProjectionSpec
pub const fn projection(&self) -> ProjectionSpec
Returns descriptor-owned boundary projections.
Sourcepub const fn context(&self) -> &ErrorContext
pub const fn context(&self) -> &ErrorContext
Returns the typed context retained by this error.
Sourcepub fn public_view(&self) -> Result<PublicErrorView<'_>, ViewContextViolation>
pub fn public_view(&self) -> Result<PublicErrorView<'_>, ViewContextViolation>
Creates a descriptor-validated public projection.
§Errors
Returns an error when the retained context does not match the selected catalog descriptor.
Sourcepub fn diagnostic_view(
&self,
) -> Result<DiagnosticView<'_>, ViewContextViolation>
pub fn diagnostic_view( &self, ) -> Result<DiagnosticView<'_>, ViewContextViolation>
Creates a descriptor-validated diagnostic projection.
The view never includes the source, caller location, or backtrace.
§Errors
Returns an error when the retained context does not match the selected catalog descriptor.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()