Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 90c416c

Browse files
committed
Better names
1 parent 95d537d commit 90c416c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ macro_rules! error_chain {
462462

463463
$(
464464
$(#[$meta_links])*
465-
$link_variant(e: <$link_error_path as $crate::Error>::ErrorKind) {
465+
$link_variant(e: <$link_error_path as $crate::ChainedError>::ErrorKind) {
466466
description(e.description())
467467
display("{}", e)
468468
}
@@ -482,8 +482,8 @@ macro_rules! error_chain {
482482

483483
$(
484484
$(#[$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 {
487487
$error_kind_name::$link_variant(e)
488488
}
489489
}
@@ -501,15 +501,15 @@ macro_rules! error_chain {
501501
}
502502
}
503503

504-
impl $crate::Error for $error_name {
504+
impl $crate::ChainedError for $error_name {
505505
type ErrorKind = $error_kind_name;
506506

507507
fn new(kind: $error_kind_name, backtrace: (Option<Box<::std::error::Error + Send + 'static>>,
508508
Option<::std::sync::Arc<$crate::Backtrace>>)) -> $error_name {
509509
$error_name(kind, backtrace)
510510
}
511511

512-
fn backtrace_from_box(e: &(::std::error::Error + Send + 'static))
512+
fn extract_backtrace(e: &(::std::error::Error + Send + 'static))
513513
-> Option<Option<::std::sync::Arc<$crate::Backtrace>>> {
514514
if let Some(e) = e.downcast_ref::<$error_name>() {
515515
Some((e.1).1.clone())
@@ -676,7 +676,7 @@ pub fn make_backtrace() -> Option<Arc<Backtrace>> {
676676

677677
/// This trait is an implementation detail which must be implemented on each
678678
/// 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 {
680680
/// Associated kind type.
681681
type ErrorKind;
682682
/// Creates an error from it's parts.
@@ -687,12 +687,12 @@ pub trait Error: error::Error + Send + 'static {
687687
/// to avoid generating a new one. It would be better to not
688688
/// define this in the macro, but types need some additional
689689
/// machinery to make it work.
690-
fn backtrace_from_box(e: &(error::Error + Send + 'static))
690+
fn extract_backtrace(e: &(error::Error + Send + 'static))
691691
-> Option<Option<Arc<Backtrace>>>;
692692
}
693693

694694
/// Additionnal methods for `Result`, for easy interaction with this crate.
695-
pub trait ResultExt<T, E: Error> {
695+
pub trait ResultExt<T, E: ChainedError> {
696696
/// If the `Result` is an `Err` then `chain_err` evaluates the closure,
697697
/// which returns *some type that can be converted to `ErrorKind`*, boxes
698698
/// the original error to store as the cause, then returns a new error
@@ -702,13 +702,13 @@ pub trait ResultExt<T, E: Error> {
702702
EK: Into<E::ErrorKind>;
703703
}
704704

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 {
706706
fn chain_err<F, EK>(self, callback: F) -> Result<T, E>
707707
where F: FnOnce() -> EK,
708708
EK: Into<E::ErrorKind> {
709709
self.map_err(move |e| {
710710
let backtrace =
711-
E::backtrace_from_box(&e).unwrap_or_else(make_backtrace);
711+
E::extract_backtrace(&e).unwrap_or_else(make_backtrace);
712712

713713
E::new(callback().into(), (Some(Box::new(e)), backtrace))
714714
})

0 commit comments

Comments
 (0)