#[non_exhaustive]pub enum JsonError {
Serialize {
source: Error,
},
Deserialize {
source: Error,
},
}json only.Expand description
JsonSerializer failures. Display names the operation, the error class
(serde_json::error::Category), and the line/column — never serde_json::Error’s own
message, which for a data error embeds a fragment of the value it rejected (e.g.
invalid type: string "sk-live-…", expected u64). The full underlying error, message
included, is still reachable via std::error::Error::source for a caller that
deliberately wants it — that caller’s own logging then owns not leaking a payload
fragment, the same rule this type upholds by default.
Debug is a manual impl, never derived: serde_json::Error’s own Debug embeds its
Display message (the same payload fragment Display above must avoid), so deriving
here would leak through {:?} even though Display is safe.
use reliar_core::{JsonSerializer, Serializer};
#[derive(serde::Serialize, serde::Deserialize)]
struct Ping;
impl reliar_core::Message for Ping {
const TYPE: &'static str = "ping";
const VERSION: u16 = 1;
}
let result = JsonSerializer.deserialize::<Ping>(b"not json");
let err = match result {
Ok(_) => unreachable!("not valid JSON"),
Err(err) => err,
};
// The message never echoes a fragment of the rejected payload.
assert!(err.to_string().starts_with("failed to deserialize from JSON:"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Trait Implementations§
Source§impl Error for JsonError
impl Error for JsonError
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()