diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-04-21 09:15:19 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-21 09:15:19 -0700 |
commit | 5dd623d3b1e47e5e22a430f74aaf7015fccc1380 (patch) | |
tree | e15b96d7e1656fddbaf7fb3e4a51fbd83460b98e /src/decoder/mod.rs | |
parent | 41563ee01b4eb3481207a88bbb2e3a54d6e96b2b (diff) | |
parent | 6e2f2c39e48fb5ec067b144ec39e9e32121615de (diff) | |
download | milf-rs-5dd623d3b1e47e5e22a430f74aaf7015fccc1380.tar.gz milf-rs-5dd623d3b1e47e5e22a430f74aaf7015fccc1380.zip |
Merge pull request #61 from oli-obk/serde
Serde
Diffstat (limited to 'src/decoder/mod.rs')
-rw-r--r-- | src/decoder/mod.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index a3cc29a..62de223 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -35,6 +35,8 @@ pub enum DecodeErrorKind { ApplicationError(String), /// A field was expected, but none was found. ExpectedField(/* type */ Option<&'static str>), + /// A field was found, but it was not an expected one. + UnknownField, /// A field was found, but it had the wrong type. ExpectedType(/* expected */ &'static str, /* found */ &'static str), /// The nth map key was expected, but none was found. @@ -149,6 +151,7 @@ impl fmt::Display for DecodeError { None => write!(f, "expected a value"), } } + UnknownField => write!(f, "unknown field"), ExpectedType(expected, found) => { fn humanize(s: &str) -> String { if s == "section" { @@ -194,6 +197,7 @@ impl error::Error for DecodeError { match self.kind { ApplicationError(ref s) => &**s, ExpectedField(..) => "expected a field", + UnknownField => "found an unknown field", ExpectedType(..) => "expected a type", ExpectedMapKey(..) => "expected a map key", ExpectedMapElement(..) => "expected a map element", |