pub struct ErrorContext {
pub message: String,
pub code: Option<i64>,
pub component: Option<SzComponent>,
pub source: Option<Box<dyn Error + Send + Sync>>,
}Expand description
Error context carried by each SzError variant.
Every SzError you receive from an SDK call contains an ErrorContext
with details from the native Senzing library. You access these through
the convenience methods on SzError itself — error_code(),
message(), component() — rather
than reading ErrorContext fields directly.
Fields§
§message: StringHuman-readable error message
code: Option<i64>Optional Senzing native error code
component: Option<SzComponent>Optional SDK component that generated the error
source: Option<Box<dyn Error + Send + Sync>>Optional underlying cause of this error
Implementations§
Source§impl ErrorContext
impl ErrorContext
Sourcepub fn with_code<S: Into<String>>(
message: S,
code: i64,
component: SzComponent,
) -> Self
pub fn with_code<S: Into<String>>( message: S, code: i64, component: SzComponent, ) -> Self
Creates an ErrorContext with message, code, and component
Sourcepub fn with_source<E>(self, source: E) -> Self
pub fn with_source<E>(self, source: E) -> Self
Adds a source error to this context
Source§impl ErrorContext
impl ErrorContext
Sourcepub fn chain_source<E>(self, source: E) -> Self
pub fn chain_source<E>(self, source: E) -> Self
Adds a source error (builder pattern)
This is useful for chaining error construction:
use sz_rust_sdk::error::ErrorContext;
let ctx = ErrorContext::new("Parse failed")
.with_source(std::io::Error::other("IO error"));Trait Implementations§
Source§impl Debug for ErrorContext
impl Debug for ErrorContext
Auto Trait Implementations§
impl Freeze for ErrorContext
impl !RefUnwindSafe for ErrorContext
impl Send for ErrorContext
impl Sync for ErrorContext
impl Unpin for ErrorContext
impl !UnwindSafe for ErrorContext
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