simplify error reporting

This commit is contained in:
Erick Tryzelaar
2014-08-05 23:02:15 -04:00
parent 14d2254b2b
commit 005b124cd3
8 changed files with 120 additions and 118 deletions
+13 -13
View File
@@ -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.