@@ -548,8 +548,32 @@ impl de::Error for Error {
548
548
}
549
549
550
550
impl fmt:: Display for Error {
551
- fn fmt ( & self , _f : & mut fmt:: Formatter ) -> fmt:: Result {
552
- unreachable ! ( )
551
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
552
+ write ! ( f, "{}" , match self {
553
+ Error :: EofWhileParsingList => "EOF while parsing a list." ,
554
+ Error :: EofWhileParsingObject => "EOF while parsing an object." ,
555
+ Error :: EofWhileParsingString => "EOF while parsing a string." ,
556
+ Error :: EofWhileParsingValue => "EOF while parsing a JSON value." ,
557
+ Error :: ExpectedColon => "Expected this character to be a `':'`." ,
558
+ Error :: ExpectedListCommaOrEnd => "Expected this character to be either a `','` or\
559
+ a \
560
+ `']'`.",
561
+ Error :: ExpectedObjectCommaOrEnd => "Expected this character to be either a `','` \
562
+ or a \
563
+ `'}'`.",
564
+ Error :: ExpectedSomeIdent => "Expected to parse either a `true`, `false`, or a \
565
+ `null`.",
566
+ Error :: ExpectedSomeValue => "Expected this character to start a JSON value." ,
567
+ Error :: InvalidNumber => "Invalid number." ,
568
+ Error :: InvalidType => "Invalid type" ,
569
+ Error :: InvalidUnicodeCodePoint => "Invalid unicode code point." ,
570
+ Error :: KeyMustBeAString => "Object key is not a string." ,
571
+ Error :: TrailingCharacters => "JSON has non-whitespace trailing characters after \
572
+ the \
573
+ value.",
574
+ Error :: TrailingComma => "JSON has a comma after the last value in an array or map." ,
575
+ _ => "Invalid JSON"
576
+ } )
553
577
}
554
578
}
555
579
0 commit comments