Skip to content
Myr

Change all remaining exception related wording

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 68dcc84 · Browse files · 2 files+13 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−13 removed

  • other:+13 added−13 removed

2 files+13 added−13 removed

modified:src/error.rs+12 added-12 removed
18 unmodified lines
19 inner: Box<ErrorImpl<()>>,20}2122impl Error {23 /// Create a new exception from any error type.23 /// Create a new error object from any error type.24 ///25 /// The error type must be threadsafe and `'static`, so that the `Error` will be as well.26 ///27 /// If the error type does not provide a backtrace, a backtrace will be created here to ensure
35 unmodified lines
63 }64 }65 }6667 /// View this exception as the underlying error.67 /// View this error object as the underlying error.68 pub fn as_error(&self) -> &(dyn StdError + Send + Sync + 'static) {69 &**self70 }7172 /// View this exception as the underlying error, mutably.72 /// View this error object as the underlying error, mutably.73 pub fn as_error_mut(&mut self) -> &mut (dyn StdError + Send + Sync + 'static) {74 &mut **self75 }76
4 unmodified lines
81 self.inner82 .backtrace83 .as_ref()84 .or_else(|| self.inner.error().backtrace())85 .expect("exception backtrace capture failed")85 .expect("backtrace capture failed")86 }8788 /// An iterator of errors contained by this Error.89 ///90 /// This iterator will visit every error in the "cause chain" of this exception, beginning with91 /// the error that this exception was created from.90 /// This iterator will visit every error in the "cause chain" of this error object, beginning with91 /// the error that this error object was created from.92 pub fn errors(&self) -> Errors<'_> {93 Errors {94 next: Some(self.inner.error()),95 }96 }9798 /// Returns `true` if `E` is the type wrapped by this exception.98 /// Returns `true` if `E` is the type wrapped by this error object.99 pub fn is<E: Display + Debug + Send + Sync + 'static>(&self) -> bool {100 TypeId::of::<E>() == self.inner.type_id101 }102103 /// Attempt to downcast the exception to a concrete type.103 /// Attempt to downcast the error object to a concrete type.104 pub fn downcast<E: Display + Debug + Send + Sync + 'static>(self) -> Result<E, Error> {105 if let Some(error) = self.downcast_ref::<E>() {106 unsafe {107 let error = ptr::read(error);
5 unmodified lines
113 Err(self)114 }115 }116117 /// Downcast this exception by reference.117 /// Downcast this error object by reference.118 pub fn downcast_ref<E: Display + Debug + Send + Sync + 'static>(&self) -> Option<&E> {119 if self.is::<E>() {120 unsafe { Some(&*(self.inner.error() as *const dyn StdError as *const E)) }121 } else {122 None123 }124 }125126 /// Downcast this exception by mutable reference.126 /// Downcast this error object by mutable reference.127 pub fn downcast_mut<E: Display + Debug + Send + Sync + 'static>(&mut self) -> Option<&mut E> {128 if self.is::<E>() {129 unsafe { Some(&mut *(self.inner.error_mut() as *mut dyn StdError as *mut E)) }130 } else {
145 unmodified lines
276 use std::marker::Unpin;277 use std::mem;278279 #[test]280 fn size_of_exception() {280 fn size_of_error() {281 assert_eq!(mem::size_of::<Error>(), mem::size_of::<usize>());282 }283284 #[allow(dead_code)]285 fn assert_exception_autotraits()285 fn assert_error_autotraits()286 where287 Error: Unpin + Send + Sync + 'static,288 {289 }
28 unmodified lines
modified:src/lib.rs+1 added-1 removed
16 unmodified lines
17 return std::result::Result::Err(std::convert::From::from($err));18 };19}2021/// Construct an ad-hoc exception from a string.21/// Construct an ad-hoc error from a string.22///23/// This evaluates to an `Error`. It can take either just a string, or a format string with24/// arguments. It also can take any custom type which implements `Debug` and `Display`.25#[macro_export]
4 unmodified lines