diff options
author | Sam Scott <sam.scott89@gmail.com> | 2017-11-09 16:15:24 +0000 |
---|---|---|
committer | Sam Scott <sam.scott89@gmail.com> | 2017-11-09 16:37:53 +0000 |
commit | 32c685bf7472ebbc8f10b9d9e57f29f2d7501566 (patch) | |
tree | 00e7e887c50e34ed9476313fa979a9614b4767c7 /src/error.rs | |
parent | 1ee313aa2998feed7d1721e0df8db0e7004fb35d (diff) |
Implement `strict` option feature.
Permits encoded brackets, and will generally tolerate parsing
errors where possible.
Permitting, for example, `a%5B[0%5D=1` to decode as `a: vec![1]`.
Default behaviour is strict.
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/error.rs b/src/error.rs index 44459c5..555bf5e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,10 +9,13 @@ use std::string; error_chain! { errors { - Custom(msg: String) - Parse(msg: String, pos: (usize, usize)) { + Custom(msg: String) { + description("miscellaneous failure") + display("failed with reason: {}", msg) + } + Parse(msg: String, pos: usize) { description("parsing failure") - display("parsing failed with error: '{}' at position: {:?}", msg, pos) + display("parsing failed with error: '{}' at position: {}", msg, pos) } Unsupported } @@ -35,7 +38,7 @@ impl Error { } /// Generate a parsing error message with position. - pub fn parse_err<T>(msg: T, position: (usize, usize)) -> Self + pub fn parse_err<T>(msg: T, position: usize) -> Self where T: Display { ErrorKind::Parse(msg.to_string(), position).into() } |