Trait trackable::error::ErrorKindExt [−][src]
An extention of ErrorKind
trait.
This provides convenient functions to create a TrackableError
instance of this kind.
Provided methods
fn error(self) -> TrackableError<Self>
[src]
Makes a TrackableError
instance without cause.
Examples
use std::error::Error; use trackable::error::{Failed, ErrorKindExt}; let e = Failed.error(); assert!(e.cause().is_none());
fn cause<E>(self, cause: E) -> TrackableError<Self> where
E: Into<BoxError>,
[src]
E: Into<BoxError>,
Makes a TrackableError
instance with the specified cause
.
Examples
use std::error::Error; use trackable::error::{Failed, ErrorKindExt}; let e = Failed.cause("something wrong"); assert_eq!(e.cause().unwrap().to_string(), "something wrong");
fn takes_over<F, K>(self, from: F) -> TrackableError<Self> where
F: Into<TrackableError<K>>,
K: ErrorKind + Send + Sync + 'static,
[src]
F: Into<TrackableError<K>>,
K: ErrorKind + Send + Sync + 'static,
Takes over from other TrackableError
instance.
The history of from
will be preserved.
Examples
use trackable::error::{ErrorKind, ErrorKindExt}; #[derive(Debug)] struct Kind0; impl ErrorKind for Kind0 {} #[derive(Debug)] struct Kind1; impl ErrorKind for Kind1 {} fn main() { let e = Kind0.error(); let e = track!(e); let e = Kind1.takes_over(e); let e = track!(e); assert_eq!(format!("\nERROR: {}", e).replace('\\', "/"), r#" ERROR: Kind1 HISTORY: [0] at src/error.rs:17 [1] at src/error.rs:20 "#); }