diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-10-03 14:24:49 -0700 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-11-02 15:31:52 -0800 |
| commit | 7c152f870da62348ec5a0d9104c20db69910a415 (patch) | |
| tree | 226afdcba9a46822fe952e62cb12e7e5702326b5 /src/libserialize/base64.rs | |
| parent | 6815c2e8e8dae3d8dedfe95e985a79c57841bdb2 (diff) | |
Add Error impls to a few key error types
Diffstat (limited to 'src/libserialize/base64.rs')
| -rw-r--r-- | src/libserialize/base64.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index c999157b89a..e69a0ea7929 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -13,6 +13,7 @@ //! Base64 binary-to-text encoding use std::fmt; use std::string; +use std::error; /// Available encoding character sets pub enum CharacterSet { @@ -178,6 +179,19 @@ impl fmt::Show for FromBase64Error { } } +impl error::Error for FromBase64Error { + fn description(&self) -> &str { + match *self { + InvalidBase64Byte(_, _) => "invalid character", + InvalidBase64Length => "invalid length", + } + } + + fn detail(&self) -> Option<String> { + Some(self.to_string()) + } +} + impl<'a> FromBase64 for &'a str { /** * Convert any base64 encoded string (literal, `@`, `&`, or `~`) |
