Add a string argument to Error::syntax()

This commit is contained in:
Erick Tryzelaar
2015-08-07 08:08:56 -07:00
parent 2aeb51ad51
commit 7fb2bd50bf
13 changed files with 51 additions and 45 deletions
+2 -2
View File
@@ -152,7 +152,7 @@ impl From<de::value::Error> for Error {
fn from(error: de::value::Error) -> Error {
match error {
de::value::Error::SyntaxError => {
de::Error::syntax()
Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)
}
de::value::Error::EndOfStreamError => {
de::Error::end_of_stream()
@@ -168,7 +168,7 @@ impl From<de::value::Error> for Error {
}
impl de::Error for Error {
fn syntax() -> Error {
fn syntax(_: &str) -> Error {
Error::SyntaxError(ErrorCode::ExpectedSomeValue, 0, 0)
}
+5 -5
View File
@@ -700,7 +700,7 @@ impl de::Deserializer for Deserializer {
{
let value = match self.value.take() {
Some(Value::Object(value)) => value,
Some(_) => { return Err(de::Error::syntax()); }
Some(_) => { return Err(de::Error::syntax("expected an enum")); }
None => { return Err(de::Error::end_of_stream()); }
};
@@ -708,12 +708,12 @@ impl de::Deserializer for Deserializer {
let (variant, value) = match iter.next() {
Some(v) => v,
None => return Err(de::Error::syntax()),
None => return Err(de::Error::syntax("expected a variant name")),
};
// enums are encoded in json as maps with a single key:value pair
match iter.next() {
Some(_) => Err(de::Error::syntax()),
Some(_) => Err(de::Error::syntax("expected map")),
None => visitor.visit(VariantDeserializer {
de: self,
val: Some(value),
@@ -768,7 +768,7 @@ impl<'a> de::VariantVisitor for VariantDeserializer<'a> {
visitor,
)
} else {
Err(de::Error::syntax())
Err(de::Error::syntax("expected a tuple"))
}
}
@@ -788,7 +788,7 @@ impl<'a> de::VariantVisitor for VariantDeserializer<'a> {
visitor,
)
} else {
Err(de::Error::syntax())
Err(de::Error::syntax("expected a struct"))
}
}
}