mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 15:25:38 +00:00
Update the location of json errors coming from "Deserialize"
This commit is contained in:
parent
3167da72d8
commit
bfe7a04c4d
@ -97,7 +97,7 @@ impl<Iter> Deserializer<Iter>
|
||||
return Err(self.error(ErrorCode::EOFWhileParsingValue));
|
||||
}
|
||||
|
||||
match self.ch_or_null() {
|
||||
let value = match self.ch_or_null() {
|
||||
b'n' => {
|
||||
try!(self.parse_ident(b"ull"));
|
||||
visitor.visit_unit()
|
||||
@ -127,6 +127,12 @@ impl<Iter> Deserializer<Iter>
|
||||
_ => {
|
||||
Err(self.error(ErrorCode::ExpectedSomeValue))
|
||||
}
|
||||
};
|
||||
|
||||
match value {
|
||||
Ok(value) => Ok(value),
|
||||
Err(Error::SyntaxError(code, _, _)) => Err(self.error(code)),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -861,9 +861,9 @@ fn test_parse_object() {
|
||||
#[test]
|
||||
fn test_parse_struct() {
|
||||
test_parse_err::<Outer>(vec![
|
||||
("5", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)),
|
||||
("\"hello\"", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)),
|
||||
("{\"inner\": true}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)),
|
||||
("5", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 2)),
|
||||
("\"hello\"", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 8)),
|
||||
("{\"inner\": true}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 15)),
|
||||
]);
|
||||
|
||||
test_parse_ok(vec![
|
||||
@ -924,10 +924,10 @@ fn test_parse_enum_errors() {
|
||||
("{}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 2)),
|
||||
("{\"Dog\":", Error::SyntaxError(ErrorCode::EOFWhileParsingValue, 1, 8)),
|
||||
("{\"Dog\":}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 8)),
|
||||
("{\"unknown\":[]}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)),
|
||||
("{\"Dog\":{}}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)),
|
||||
("{\"Frog\":{}}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)),
|
||||
("{\"Cat\":[]}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)),
|
||||
("{\"unknown\":[]}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 11)),
|
||||
("{\"Dog\":{}}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 9)),
|
||||
("{\"Frog\":{}}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 10)),
|
||||
("{\"Cat\":[]}", Error::SyntaxError(ErrorCode::ExpectedSomeValue, 1, 9)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user