pub struct ValueWireJsonError { /* private fields */ }json only.Expand description
Privacy-safe classification and source position for a JSON wire failure.
Obtain this metadata from ValueWireDecodeError::InvalidJson rather than
constructing it directly. It contains only the Serde category and source
coordinates; it does not retain the input or detailed error message. A
coordinate of zero means that the source position is unavailable, as can
happen for target-type failures after decoding through a unique-key tree.
Direct conversion from a Serde error preserves its source coordinates.
§Examples
use qubit_value::ValueWireDecodeError;
use qubit_value::ValueWireJsonError;
use serde_json::error::Category;
fn check_metadata(metadata: &ValueWireJsonError) {
assert_eq!(metadata.classify(), Category::Data);
assert!(metadata.is_data());
assert!(metadata.line() > 0);
assert!(metadata.column() > 0);
}
let source = serde_json::from_str::<u64>(r#""not a number""#).unwrap_err();
let error = ValueWireDecodeError::from(source);
let ValueWireDecodeError::InvalidJson(metadata) = error else {
panic!("direct Serde conversion must preserve safe metadata");
};
check_metadata(&metadata);Implementations§
Source§impl ValueWireJsonError
impl ValueWireJsonError
Sourcepub fn line(&self) -> usize
pub fn line(&self) -> usize
Returns the one-based input line, or zero when unavailable.
§Returns
The source line, or zero if no source position is available.
Sourcepub fn column(&self) -> usize
pub fn column(&self) -> usize
Returns the one-based input column, or zero when unavailable.
§Returns
The source column, or zero if no source position is available.
Sourcepub fn is_io(&self) -> bool
pub fn is_io(&self) -> bool
Returns whether the error is an I/O failure.
§Returns
true if the category is Category::Io; otherwise, false.
Sourcepub fn is_syntax(&self) -> bool
pub fn is_syntax(&self) -> bool
Returns whether the error is a JSON syntax failure.
§Returns
true if the category is Category::Syntax; otherwise, false.
Trait Implementations§
Source§impl Debug for ValueWireJsonError
impl Debug for ValueWireJsonError
Source§impl Display for ValueWireJsonError
impl Display for ValueWireJsonError
Source§impl Error for ValueWireJsonError
impl Error for ValueWireJsonError
1.30.0 · 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
use the Display impl or to_string()