MCPcopy Create free account
hub / github.com/csskit/csskit / from

Method from

crates/csskit_lsp/src/jsonrpc/message.rs:145–164  ·  view source on GitHub ↗
(error: ParseError)

Source from the content-addressed store, hash-verified

143
144impl From<ParseError> for io::Error {
145 fn from(error: ParseError) -> Self {
146 match error {
147 ParseError::NoLength => io::Error::new(io::ErrorKind::InvalidData, "could not read content-length header"),
148 ParseError::CouldNotDecodeHeader => io::Error::new(io::ErrorKind::InvalidData, "could not decode headers"),
149 ParseError::HeaderDecodeMismatch(expected, actual) => io::Error::new(
150 io::ErrorKind::InvalidData,
151 format!("failed to fully parse headers, expected {expected} but parsing ended at {actual} bytes"),
152 ),
153 ParseError::InvalidHeader(string) => {
154 io::Error::new(io::ErrorKind::InvalidData, format!("saw invalid header {string}"))
155 }
156 ParseError::Encode(e) => e,
157 ParseError::Utf8(e) => io::Error::new(io::ErrorKind::InvalidData, format!("Utf8 decode error: {e}")),
158 ParseError::InvalidContentLength(e) => {
159 io::Error::new(io::ErrorKind::InvalidData, format!("invalid content-length: {e}"))
160 }
161 ParseError::Headers(e) => io::Error::new(io::ErrorKind::InvalidData, format!("invalid headers: {e}")),
162 ParseError::Body(e) => io::Error::new(io::ErrorKind::InvalidData, format!("invalid body: {e}")),
163 }
164 }
165}
166
167impl From<io::Error> for ParseError {

Callers

nothing calls this directly

Calls 3

RequestClass · 0.85
ResponseEnum · 0.85
NotificationClass · 0.85

Tested by

no test coverage detected