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
+8 -2
View File
@@ -804,7 +804,7 @@ fn deserialize_field_visitor(
let index_body = quote_expr!(cx,
match value {
$index_field_arms
_ => { Err(::serde::de::Error::syntax()) }
_ => { Err(::serde::de::Error::syntax("expected a field")) }
}
);
@@ -903,7 +903,13 @@ fn deserialize_field_visitor(
// TODO: would be better to generate a byte string literal match
match ::std::str::from_utf8(value) {
Ok(s) => self.visit_str(s),
_ => Err(::serde::de::Error::syntax()),
_ => {
Err(
::serde::de::Error::syntax(
"could not convert a byte string to a String"
)
)
}
}
}
}