From 94d944c9e07847e377d2c56b252b9ec44d09cc44 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 4 Oct 2019 23:44:16 -0400 Subject: [PATCH] Change all remaining exception related wording --- src/error.rs | 24 ++++++++++++------------ src/lib.rs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/error.rs b/src/error.rs index c826e04..03dbd0a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -20,7 +20,7 @@ pub struct Error { } impl Error { - /// Create a new exception from any error type. + /// Create a new error object from any error type. /// /// The error type must be threadsafe and `'static`, so that the `Error` will be as well. /// @@ -64,12 +64,12 @@ impl Error { } } - /// View this exception as the underlying error. + /// View this error object as the underlying error. pub fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) { &**self } - /// View this exception as the underlying error, mutably. + /// View this error object as the underlying error, mutably. pub fn as_error_mut(&mut self) -> &mut (dyn StdError + Send + Sync + 'static) { &mut **self } @@ -82,25 +82,25 @@ impl Error { .backtrace .as_ref() .or_else(|| self.inner.error().backtrace()) - .expect("exception backtrace capture failed") + .expect("backtrace capture failed") } /// An iterator of errors contained by this Error. /// - /// This iterator will visit every error in the "cause chain" of this exception, beginning with - /// the error that this exception was created from. + /// This iterator will visit every error in the "cause chain" of this error object, beginning with + /// the error that this error object was created from. pub fn errors(&self) -> Errors<'_> { Errors { next: Some(self.inner.error()), } } - /// Returns `true` if `E` is the type wrapped by this exception. + /// Returns `true` if `E` is the type wrapped by this error object. pub fn is(&self) -> bool { TypeId::of::() == self.inner.type_id } - /// Attempt to downcast the exception to a concrete type. + /// Attempt to downcast the error object to a concrete type. pub fn downcast(self) -> Result { if let Some(error) = self.downcast_ref::() { unsafe { @@ -114,7 +114,7 @@ impl Error { } } - /// Downcast this exception by reference. + /// Downcast this error object by reference. pub fn downcast_ref(&self) -> Option<&E> { if self.is::() { unsafe { Some(&*(self.inner.error() as *const dyn StdError as *const E)) } @@ -123,7 +123,7 @@ impl Error { } } - /// Downcast this exception by mutable reference. + /// Downcast this error object by mutable reference. pub fn downcast_mut(&mut self) -> Option<&mut E> { if self.is::() { unsafe { Some(&mut *(self.inner.error_mut() as *mut dyn StdError as *mut E)) } @@ -277,12 +277,12 @@ mod repr_correctness { use std::mem; #[test] - fn size_of_exception() { + fn size_of_error() { assert_eq!(mem::size_of::(), mem::size_of::()); } #[allow(dead_code)] - fn assert_exception_autotraits() + fn assert_error_autotraits() where Error: Unpin + Send + Sync + 'static, { diff --git a/src/lib.rs b/src/lib.rs index 416eaec..03dea24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ macro_rules! bail { }; } -/// Construct an ad-hoc exception from a string. +/// Construct an ad-hoc error from a string. /// /// This evaluates to an `Error`. It can take either just a string, or a format string with /// arguments. It also can take any custom type which implements `Debug` and `Display`.