mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 07:08:02 +00:00
simplify error reporting
This commit is contained in:
+13
-13
@@ -526,7 +526,7 @@ impl de::Deserializable for Json {
|
||||
object.insert(name.to_string(), List(fields));
|
||||
Ok(Object(object))
|
||||
}
|
||||
de::End => d.syntax_error(de::End),
|
||||
de::End => Err(d.syntax_error(de::End)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -611,16 +611,16 @@ impl Iterator<Result<de::Token, ParserError>> for JsonDeserializer {
|
||||
}
|
||||
|
||||
impl de::Deserializer<ParserError> for JsonDeserializer {
|
||||
fn end_of_stream_error<T>(&self) -> Result<T, ParserError> {
|
||||
Err(SyntaxError(EOFWhileParsingValue, 0, 0))
|
||||
fn end_of_stream_error(&self) -> ParserError {
|
||||
SyntaxError(EOFWhileParsingValue, 0, 0)
|
||||
}
|
||||
|
||||
fn syntax_error<T>(&self, _token: de::Token) -> Result<T, ParserError> {
|
||||
Err(SyntaxError(InvalidSyntax, 0, 0))
|
||||
fn syntax_error(&self, _token: de::Token) -> ParserError {
|
||||
SyntaxError(InvalidSyntax, 0, 0)
|
||||
}
|
||||
|
||||
fn missing_field_error<T>(&self, field: &'static str) -> Result<T, ParserError> {
|
||||
Err(SyntaxError(MissingField(field), 0, 0))
|
||||
fn missing_field_error(&self, field: &'static str) -> ParserError {
|
||||
SyntaxError(MissingField(field), 0, 0)
|
||||
}
|
||||
|
||||
// Special case treating options as a nullable value.
|
||||
@@ -1977,16 +1977,16 @@ impl<T: Iterator<char>> Parser<T> {
|
||||
}
|
||||
|
||||
impl<T: Iterator<char>> de::Deserializer<ParserError> for Parser<T> {
|
||||
fn end_of_stream_error<U>(&self) -> Result<U, ParserError> {
|
||||
Err(SyntaxError(EOFWhileParsingValue, self.line, self.col))
|
||||
fn end_of_stream_error(&self) -> ParserError {
|
||||
SyntaxError(EOFWhileParsingValue, self.line, self.col)
|
||||
}
|
||||
|
||||
fn syntax_error<U>(&self, _token: de::Token) -> Result<U, ParserError> {
|
||||
Err(SyntaxError(InvalidSyntax, self.line, self.col))
|
||||
fn syntax_error(&self, _token: de::Token) -> ParserError {
|
||||
SyntaxError(InvalidSyntax, self.line, self.col)
|
||||
}
|
||||
|
||||
fn missing_field_error<T>(&self, field: &'static str) -> Result<T, ParserError> {
|
||||
Err(SyntaxError(MissingField(field), self.line, self.col))
|
||||
fn missing_field_error(&self, field: &'static str) -> ParserError {
|
||||
SyntaxError(MissingField(field), self.line, self.col)
|
||||
}
|
||||
|
||||
// Special case treating options as a nullable value.
|
||||
|
||||
Reference in New Issue
Block a user