diff --git a/src/libcore/error.rs b/src/libcore/error.rs index 161f6c7892163..d29964d63a58e 100644 --- a/src/libcore/error.rs +++ b/src/libcore/error.rs @@ -82,16 +82,21 @@ #![stable(feature = "rust1", since = "1.0.0")] use prelude::*; -use fmt::Display; +use fmt::{Debug, Display}; /// Base functionality for all errors in Rust. -#[unstable(feature = "core", - reason = "the exact API of this trait may change")] -pub trait Error: Display { - /// A short description of the error; usually a static string. +#[stable(feature = "rust1", since = "1.0.0")] +pub trait Error: Debug + Display + Send { + /// A short description of the error. + /// + /// The description should not contain newlines or sentence-ending + /// punctuation, to facilitate embedding in larger user-facing + /// strings. + #[stable(feature = "rust1", since = "1.0.0")] fn description(&self) -> &str; /// The lower-level cause of this error, if any. + #[stable(feature = "rust1", since = "1.0.0")] fn cause(&self) -> Option<&Error> { None } } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 43eec69527420..4def601f1c0e7 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -258,7 +258,7 @@ impl FromError> for Error { } #[stable(feature = "rust1", since = "1.0.0")] -impl error::Error for IntoInnerError { +impl error::Error for IntoInnerError { fn description(&self) -> &str { error::Error::description(self.error()) } diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 01eeed4fb54d0..2cf0df305c21c 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -977,7 +977,7 @@ impl fmt::Display for SendError { } #[stable(feature = "rust1", since = "1.0.0")] -impl error::Error for SendError { +impl error::Error for SendError { fn description(&self) -> &str { "sending on a closed channel" @@ -1013,7 +1013,7 @@ impl fmt::Display for TrySendError { } #[stable(feature = "rust1", since = "1.0.0")] -impl error::Error for TrySendError { +impl error::Error for TrySendError { fn description(&self) -> &str { match *self { diff --git a/src/libstd/sync/poison.rs b/src/libstd/sync/poison.rs index 2587ff5238ea7..c07c83d37f488 100644 --- a/src/libstd/sync/poison.rs +++ b/src/libstd/sync/poison.rs @@ -105,11 +105,11 @@ impl fmt::Debug for PoisonError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for PoisonError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.description().fmt(f) + "poisoned lock: another task failed inside".fmt(f) } } -impl Error for PoisonError { +impl Error for PoisonError { fn description(&self) -> &str { "poisoned lock: another task failed inside" } @@ -161,13 +161,13 @@ impl fmt::Debug for TryLockError { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Display for TryLockError { +impl fmt::Display for TryLockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.description().fmt(f) } } -impl Error for TryLockError { +impl Error for TryLockError { fn description(&self) -> &str { match *self { TryLockError::Poisoned(ref p) => p.description(), diff --git a/src/rustbook/error.rs b/src/rustbook/error.rs index 294b4e556694a..e896dee27919e 100644 --- a/src/rustbook/error.rs +++ b/src/rustbook/error.rs @@ -20,6 +20,7 @@ pub type CommandError = Box; pub type CommandResult = Result; pub fn err(s: &str) -> CliError { + #[derive(Debug)] struct E(String); impl Error for E {