pub struct Error {
pub code: ErrorCode,
pub message: String,
pub subject: Option<Subject>,
pub correlation_id: Option<CorrelationId>,
pub causation_id: Option<CausationId>,
pub details: Option<Value>,
}Expand description
The canonical error type. Transport adapters project this into GraphQL errors, MQTT error topics, SSE error frames, etc. Transport adapters must not define their own error types.
Fields§
§code: ErrorCodeCanonical error code.
message: StringHuman-readable error message.
subject: Option<Subject>Subject the error relates to.
correlation_id: Option<CorrelationId>Correlation id.
causation_id: Option<CausationId>Causation id.
details: Option<Value>Optional structured details.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(code: ErrorCode, message: impl Into<String>) -> Self
pub fn new(code: ErrorCode, message: impl Into<String>) -> Self
Construct an error with a code and message.
Sourcepub fn transport_error(msg: impl Into<String>) -> Self
pub fn transport_error(msg: impl Into<String>) -> Self
Construct a transport error.
Sourcepub fn resolver_error(msg: impl Into<String>) -> Self
pub fn resolver_error(msg: impl Into<String>) -> Self
Construct a resolver error.
Sourcepub fn cache_miss(msg: impl Into<String>) -> Self
pub fn cache_miss(msg: impl Into<String>) -> Self
Construct a cache-miss error.
Sourcepub fn validation_error(msg: impl Into<String>) -> Self
pub fn validation_error(msg: impl Into<String>) -> Self
Construct a validation error.
Sourcepub fn internal_error(msg: impl Into<String>) -> Self
pub fn internal_error(msg: impl Into<String>) -> Self
Construct an internal error.
Sourcepub fn with_subject(self, s: Subject) -> Self
pub fn with_subject(self, s: Subject) -> Self
Set the subject.
Sourcepub fn with_correlation(self, id: CorrelationId) -> Self
pub fn with_correlation(self, id: CorrelationId) -> Self
Set the correlation id.
Sourcepub fn with_causation(self, id: CausationId) -> Self
pub fn with_causation(self, id: CausationId) -> Self
Set the causation id.
Sourcepub fn with_details(self, details: Value) -> Self
pub fn with_details(self, details: Value) -> Self
Set structured details.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Error
impl<'de> Deserialize<'de> for Error
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 Error for Error
impl Error for Error
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 From<SubjectError> for Error
impl From<SubjectError> for Error
Source§fn from(e: SubjectError) -> Self
fn from(e: SubjectError) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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