ErrorContext

Struct ErrorContext 

Source
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: String

Human-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

Source

pub fn new<S: Into<String>>(message: S) -> Self

Creates a new ErrorContext with just a message

Source

pub fn with_code<S: Into<String>>( message: S, code: i64, component: SzComponent, ) -> Self

Creates an ErrorContext with message, code, and component

Source

pub fn with_source<E>(self, source: E) -> Self
where E: Error + Send + Sync + 'static,

Adds a source error to this context

Source§

impl ErrorContext

Source

pub fn chain_source<E>(self, source: E) -> Self
where E: Error + Send + Sync + 'static,

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ErrorContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.