pub struct PortError { /* private fields */ }Expand description
An error from a port implementation (repository, event dispatcher,
etc.), tagged with a PortErrorKind and wrapping the underlying cause.
§Examples
use ddd_toolkit_core::port::{PortError, PortErrorKind};
let error = PortError::unavailable("connection refused");
// the kind lets a caller decide how to react, e.g. retry on `Unavailable`...
match error.kind() {
PortErrorKind::Unavailable => { /* retry later */ }
PortErrorKind::Conflict => { /* reload and retry */ }
_ => { /* give up */ }
}
// ...while std::error::Error::source() still exposes the underlying cause.
assert_eq!(error.to_string(), "Unavailable: connection refused");Implementations§
Source§impl PortError
impl PortError
Sourcepub fn new(
kind: PortErrorKind,
source: impl Into<Box<dyn Error + Sync + Send>>,
) -> PortError
pub fn new( kind: PortErrorKind, source: impl Into<Box<dyn Error + Sync + Send>>, ) -> PortError
Creates a new PortError of the given kind, wrapping source.
Sourcepub fn conflict(source: impl Into<Box<dyn Error + Sync + Send>>) -> PortError
pub fn conflict(source: impl Into<Box<dyn Error + Sync + Send>>) -> PortError
Creates a PortErrorKind::Conflict error.
Creates a PortErrorKind::Unavailable error.
Sourcepub fn other(source: impl Into<Box<dyn Error + Sync + Send>>) -> PortError
pub fn other(source: impl Into<Box<dyn Error + Sync + Send>>) -> PortError
Creates a PortErrorKind::Other error.
Sourcepub fn kind(&self) -> PortErrorKind
pub fn kind(&self) -> PortErrorKind
This error’s kind.
Trait Implementations§
Source§impl Error for PortError
impl Error for PortError
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 !RefUnwindSafe for PortError
impl !UnwindSafe for PortError
impl Freeze for PortError
impl Send for PortError
impl Sync for PortError
impl Unpin for PortError
impl UnsafeUnpin for PortError
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