mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-24 21:41:07 +00:00
fix(value): Handle the new value::Error variants when implementing Display
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ pub trait Error: Sized + error::Error {
|
|||||||
|
|
||||||
/// `Type` represents all the primitive types that can be deserialized. This is used by
|
/// `Type` represents all the primitive types that can be deserialized. This is used by
|
||||||
/// `Error::kind_mismatch`.
|
/// `Error::kind_mismatch`.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
/// Represents a `bool` type.
|
/// Represents a `bool` type.
|
||||||
Bool,
|
Bool,
|
||||||
|
|||||||
@@ -55,10 +55,12 @@ impl de::Error for Error {
|
|||||||
impl fmt::Display for Error {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::SyntaxError => formatter.write_str("SyntaxError"),
|
Error::Syntax(ref s) => write!(formatter, "Syntax error: {}", s),
|
||||||
Error::EndOfStreamError => formatter.write_str("EndOfStreamError"),
|
Error::Type(ty) => write!(formatter, "Invalid type: {:?}", ty),
|
||||||
Error::UnknownFieldError(ref field) => formatter.write_str(format!("Unknown field: {}", field).as_ref()),
|
Error::Length(len) => write!(formatter, "Invalid length: {}", len),
|
||||||
Error::MissingFieldError(ref field) => formatter.write_str(format!("Missing field: {}", field).as_ref()),
|
Error::EndOfStream => formatter.write_str("EndOfStreamError"),
|
||||||
|
Error::UnknownField(ref field) => write!(formatter, "Unknown field: {}", field),
|
||||||
|
Error::MissingField(ref field) => write!(formatter, "Missing field: {}", field),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user