@@ -462,7 +462,7 @@ macro_rules! error_chain {
462
462
463
463
$(
464
464
$( #[ $meta_links] ) *
465
- $link_variant( e: <$link_error_path as $crate:: Error >:: ErrorKind ) {
465
+ $link_variant( e: <$link_error_path as $crate:: ChainedError >:: ErrorKind ) {
466
466
description( e. description( ) )
467
467
display( "{}" , e)
468
468
}
@@ -482,8 +482,8 @@ macro_rules! error_chain {
482
482
483
483
$(
484
484
$( #[ $meta_links] ) *
485
- impl From <<$link_error_path as $crate:: Error >:: ErrorKind > for $error_kind_name {
486
- fn from( e: <$link_error_path as $crate:: Error >:: ErrorKind ) -> Self {
485
+ impl From <<$link_error_path as $crate:: ChainedError >:: ErrorKind > for $error_kind_name {
486
+ fn from( e: <$link_error_path as $crate:: ChainedError >:: ErrorKind ) -> Self {
487
487
$error_kind_name:: $link_variant( e)
488
488
}
489
489
}
@@ -501,15 +501,15 @@ macro_rules! error_chain {
501
501
}
502
502
}
503
503
504
- impl $crate:: Error for $error_name {
504
+ impl $crate:: ChainedError for $error_name {
505
505
type ErrorKind = $error_kind_name;
506
506
507
507
fn new( kind: $error_kind_name, backtrace: ( Option <Box <:: std:: error:: Error + Send + ' static >>,
508
508
Option <:: std:: sync:: Arc <$crate:: Backtrace >>) ) -> $error_name {
509
509
$error_name( kind, backtrace)
510
510
}
511
511
512
- fn backtrace_from_box ( e: & ( :: std:: error:: Error + Send + ' static ) )
512
+ fn extract_backtrace ( e: & ( :: std:: error:: Error + Send + ' static ) )
513
513
-> Option <Option <:: std:: sync:: Arc <$crate:: Backtrace >>> {
514
514
if let Some ( e) = e. downcast_ref:: <$error_name>( ) {
515
515
Some ( ( e. 1 ) . 1 . clone( ) )
@@ -676,7 +676,7 @@ pub fn make_backtrace() -> Option<Arc<Backtrace>> {
676
676
677
677
/// This trait is an implementation detail which must be implemented on each
678
678
/// ErrorKind. We can't do it globally since each ErrorKind is different.
679
- pub trait Error : error:: Error + Send + ' static {
679
+ pub trait ChainedError : error:: Error + Send + ' static {
680
680
/// Associated kind type.
681
681
type ErrorKind ;
682
682
/// Creates an error from it's parts.
@@ -687,12 +687,12 @@ pub trait Error: error::Error + Send + 'static {
687
687
/// to avoid generating a new one. It would be better to not
688
688
/// define this in the macro, but types need some additional
689
689
/// machinery to make it work.
690
- fn backtrace_from_box ( e : & ( error:: Error + Send + ' static ) )
690
+ fn extract_backtrace ( e : & ( error:: Error + Send + ' static ) )
691
691
-> Option < Option < Arc < Backtrace > > > ;
692
692
}
693
693
694
694
/// Additionnal methods for `Result`, for easy interaction with this crate.
695
- pub trait ResultExt < T , E : Error > {
695
+ pub trait ResultExt < T , E : ChainedError > {
696
696
/// If the `Result` is an `Err` then `chain_err` evaluates the closure,
697
697
/// which returns *some type that can be converted to `ErrorKind`*, boxes
698
698
/// the original error to store as the cause, then returns a new error
@@ -702,13 +702,13 @@ pub trait ResultExt<T, E: Error> {
702
702
EK : Into < E :: ErrorKind > ;
703
703
}
704
704
705
- impl < T , E > ResultExt < T , E > for Result < T , E > where E : Error {
705
+ impl < T , E > ResultExt < T , E > for Result < T , E > where E : ChainedError {
706
706
fn chain_err < F , EK > ( self , callback : F ) -> Result < T , E >
707
707
where F : FnOnce ( ) -> EK ,
708
708
EK : Into < E :: ErrorKind > {
709
709
self . map_err ( move |e| {
710
710
let backtrace =
711
- E :: backtrace_from_box ( & e) . unwrap_or_else ( make_backtrace) ;
711
+ E :: extract_backtrace ( & e) . unwrap_or_else ( make_backtrace) ;
712
712
713
713
E :: new ( callback ( ) . into ( ) , ( Some ( Box :: new ( e) ) , backtrace) )
714
714
} )
0 commit comments