| 2013 | |
| 2014 | impl fmt::Display for ParseError { |
| 2015 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 2016 | match self.kind { |
| 2017 | ParseErrorKind::OutOfRange => { |
| 2018 | write!( |
| 2019 | f, |
| 2020 | "{} is out of range for type {}", |
| 2021 | self.input.quoted(), |
| 2022 | self.type_name |
| 2023 | )?; |
| 2024 | if let Some(details) = &self.details { |
| 2025 | write!(f, ": {}", details)?; |
| 2026 | } |
| 2027 | Ok(()) |
| 2028 | } |
| 2029 | ParseErrorKind::InvalidInputSyntax => { |
| 2030 | write!(f, "invalid input syntax for type {}: ", self.type_name)?; |
| 2031 | if let Some(details) = &self.details { |
| 2032 | write!(f, "{}: ", details)?; |
| 2033 | } |
| 2034 | write!(f, "{}", self.input.quoted()) |
| 2035 | } |
| 2036 | } |
| 2037 | } |
| 2038 | } |
| 2039 | |
| 2040 | impl Error for ParseError {} |