json_gettext/value/
errors.rs

1use std::{
2    error::Error,
3    fmt::{self, Display, Formatter},
4};
5
6use crate::serde_json::Error as JSONError;
7
8#[derive(Debug)]
9pub enum JSONGetTextValueError {
10    IntegerOutOfRange,
11    ParseError(JSONError),
12}
13
14impl Display for JSONGetTextValueError {
15    #[inline]
16    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
17        match self {
18            JSONGetTextValueError::IntegerOutOfRange => f.write_str("The integer is out of range."),
19            JSONGetTextValueError::ParseError(error) => Display::fmt(error, f),
20        }
21    }
22}
23
24impl Error for JSONGetTextValueError {}
25
26impl From<JSONError> for JSONGetTextValueError {
27    #[inline]
28    fn from(error: JSONError) -> JSONGetTextValueError {
29        JSONGetTextValueError::ParseError(error)
30    }
31}