From 32c685bf7472ebbc8f10b9d9e57f29f2d7501566 Mon Sep 17 00:00:00 2001 From: Sam Scott Date: Thu, 9 Nov 2017 16:15:24 +0000 Subject: 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. --- src/error.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/error.rs') 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(msg: T, position: (usize, usize)) -> Self + pub fn parse_err(msg: T, position: usize) -> Self where T: Display { ErrorKind::Parse(msg.to_string(), position).into() } -- cgit v1.2.3