link_cli/protocol/
error.rs1use std::io;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
9pub enum ProtocolError {
10 #[error("I/O error: {0}")]
12 Io(#[from] io::Error),
13
14 #[error("malformed message: {0}")]
16 Malformed(String),
17
18 #[error("invalid LiNo: {0}")]
20 InvalidLino(String),
21
22 #[error("limit exceeded: {0}")]
24 LimitExceeded(String),
25
26 #[error("cannot encode: {0}")]
28 Unencodable(String),
29
30 #[error("server error: {0}")]
32 Remote(String),
33}
34
35impl ProtocolError {
36 pub(crate) fn malformed(message: impl Into<String>) -> Self {
37 Self::Malformed(message.into())
38 }
39}
40
41pub type ProtocolResult<T> = Result<T, ProtocolError>;