#[non_exhaustive]pub enum ReaderError {
SyntaxError(JsonSyntaxError),
UnexpectedValueType {
expected: ValueType,
actual: ValueType,
location: JsonReaderPosition,
},
UnexpectedStructure {
kind: UnexpectedStructureKind,
location: JsonReaderPosition,
},
MaxNestingDepthExceeded {
max_nesting_depth: u32,
location: JsonReaderPosition,
},
UnsupportedNumberValue {
number: String,
location: JsonReaderPosition,
},
IoError {
error: Error,
location: JsonReaderPosition,
},
}Expand description
Error which occurred while reading from a JSON reader
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SyntaxError(JsonSyntaxError)
A syntax error was encountered
UnexpectedValueType
The next JSON value had an unexpected type
This error can occur for example when trying to read a JSON number when the next value is actually a JSON boolean.
Fields
location: JsonReaderPositionLocation where the error occurred in the JSON document
UnexpectedStructure
The JSON document had an unexpected structure
This error occurs when trying to consume more elements than a JSON array or object has, or when trying to end a JSON array or object when there are still unprocessed elements in it. If these remaining elements should be ignored they can be skipped like this:
while json_reader.has_next()? {
json_reader.skip_value()?;
}Note: For a JSON object skip_name and skip_value
have to be called for every member to skip its name and value.
Fields
kind: UnexpectedStructureKindDescribes why the JSON document is considered to have an invalid structure
location: JsonReaderPositionLocation where the error occurred in the JSON document
MaxNestingDepthExceeded
The maximum nesting depth was exceeded while reading
See ReaderSettings::max_nesting_depth for more information.
Fields
location: JsonReaderPositionLocation within the JSON document
UnsupportedNumberValue
An unsupported JSON number value was encountered
See ReaderSettings::restrict_number_values for more information.
Fields
location: JsonReaderPositionLocation of the number value within the JSON document
IoError
An IO error occurred while trying to read from the underlying reader, or malformed UTF-8 data was encountered
Fields
location: JsonReaderPositionRough location where the error occurred within the JSON document
The location might not be completely accurate. Since the IO error might have been returned by the underlying reader, it might not be related to the content of the JSON document. For example the location might still point to the beginning of the current JSON value while the IO error actually occurred multiple bytes ahead while fetching more data from the underlying reader.
Trait Implementations§
Source§impl Debug for ReaderError
impl Debug for ReaderError
Source§impl Display for ReaderError
impl Display for ReaderError
Source§impl Error for ReaderError
impl Error for ReaderError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<JsonSyntaxError> for ReaderError
impl From<JsonSyntaxError> for ReaderError
Source§fn from(source: JsonSyntaxError) -> Self
fn from(source: JsonSyntaxError) -> Self
Source§impl From<ReaderError> for DeserializerError
Available on crate feature serde only.
impl From<ReaderError> for DeserializerError
serde only.