about summary refs log tree commit diff
path: root/src/libstd/error.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-23 02:41:48 +0000
committerbors <bors@rust-lang.org>2014-12-23 02:41:48 +0000
commit62fb41c32bd97c4e9bc286a1db5d7126a06b8b91 (patch)
treefc1c7ab2bf1a29879d45235acaf0126ceae4d107 /src/libstd/error.rs
parent2f3cff6956d56048ef7afb6d33e17cbdb2dcf038 (diff)
parent3583d613b9c81855feb067aeeebb525cf8a4184c (diff)
downloadrust-62fb41c32bd97c4e9bc286a1db5d7126a06b8b91.tar.gz
rust-62fb41c32bd97c4e9bc286a1db5d7126a06b8b91.zip
auto merge of #20145 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libstd/error.rs')
-rw-r--r--src/libstd/error.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 9ad2655f6e9..cd7d9aacc90 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -78,10 +78,9 @@
 //! }
 //! ```
 
-use option::Option;
-use option::Option::None;
-use kinds::Send;
-use string::String;
+use prelude::*;
+
+use str::Utf8Error;
 
 /// Base functionality for all errors in Rust.
 pub trait Error: Send {
@@ -107,3 +106,14 @@ impl<E> FromError<E> for E {
         err
     }
 }
+
+impl Error for Utf8Error {
+    fn description(&self) -> &str {
+        match *self {
+            Utf8Error::TooShort => "invalid utf-8: not enough bytes",
+            Utf8Error::InvalidByte(..) => "invalid utf-8: corrupt contents",
+        }
+    }
+
+    fn detail(&self) -> Option<String> { Some(self.to_string()) }
+}