pub struct ParseError {
pub raw_line: String,
pub raw_json: Option<Value>,
pub error_message: String,
pub method: Option<String>,
}Expand description
Error type for parsing failures that preserves the raw frame data.
Returned inside Error::Deserialization when a message from the
app-server fails to deserialize. The structured fields let consumers
render the offending frame in bug reports without grepping logs.
Two failure modes are represented:
-
Bare JSON failure — the line wasn’t valid JSON, or the JSON didn’t match the
JsonRpcMessageenvelope.raw_lineis the original line from stdout.raw_jsonis populated when the line parsed as JSON but didn’t fit the envelope;Nonewhen the line wasn’t even JSON.methodisNone. -
Typed decode failure — the envelope parsed fine (so the JSON-RPC
methodis known), but the typed payload decode (Notification::from_envelope/ServerRequest::from_envelope) failed on theparams.methodcarries the JSON-RPC method name.raw_jsoncarries theparamsvalue.raw_lineis the re-serialized envelope — wire-equivalent to what came in, suitable for pasting into a bug report.
Fields§
§raw_line: StringLine from stdout (or re-serialized envelope, for typed-decode failures).
raw_json: Option<Value>Parsed JSON value when available (the params for typed-decode
failures; the parsed line for envelope-shape failures).
error_message: StringThe underlying serde error description.
method: Option<String>JSON-RPC method name when the failure happened at the typed-decode
stage. None for bare-JSON / envelope-shape failures.
Implementations§
Source§impl ParseError
impl ParseError
Sourcepub fn from_line(line: impl Into<String>, error: Error) -> Self
pub fn from_line(line: impl Into<String>, error: Error) -> Self
Build a ParseError for a bare-JSON or envelope-shape failure.
Sourcepub fn from_envelope(
method: impl Into<String>,
params: Option<Value>,
error: Error,
) -> Self
pub fn from_envelope( method: impl Into<String>, params: Option<Value>, error: Error, ) -> Self
Build a ParseError for a typed-decode failure on a notification or
request whose envelope parsed but whose params did not match.
raw_line is reconstructed by re-serializing the envelope so consumers
can render the full offending frame even though the original line was
already consumed by the envelope decode.
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
Source§impl Error for ParseError
impl Error for ParseError
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()