Skip to main content

Module value_path

Module value_path 

Source
Expand description

Where in a serde_json::Value a deserialization error happened, found after the fact from the error message.

A path-tracking deserializer (serde_path_to_error) wraps every deserializer call and is instantiated again for every type it parses (≈ 180 KiB of a gateway binary for the node configs alone). Errors are rare and the input is at hand, so this module recovers the path once, without generics: serde’s standard messages name the offending field, variant or value (unknown field x, `missing field `x, unknown variant v``, invalid type: string "s", expected …, invalid length 3, expected …), and the tree is searched for it in document order. When the message names nothing searchable (a custom error, or a map or sequence that occurs more than once) the path is the root, and the message alone still says what is wrong.

Functions§

error_path
Path of the value error (from deserializing root) is about; the root when it cannot be told.
error_path_text
error_path in the serde_path_to_error notation: . for the root, else variables[0].value_selector.