1use crate::rpc::api_key::ApiKey;
19use crate::rpc::api_version::ApiVersion;
20use prost::DecodeError;
21use std::sync::Arc;
22use thiserror::Error;
23
24#[derive(Error, Debug)]
25#[non_exhaustive]
26pub enum RpcError {
27 #[error("Cannot write message: {0}")]
28 WriteMessageError(#[from] crate::rpc::frame::WriteError),
29
30 #[error("Cannot read framed message: {0}")]
31 ReadMessageError(#[from] crate::rpc::frame::ReadError),
32
33 #[error("Rpc Decode Error: {0}")]
34 RpcDecodeError(#[from] DecodeError),
35
36 #[error("connection error")]
37 ConnectionError(String),
38
39 #[error("IO Error: {0}")]
40 IO(#[from] std::io::Error),
41
42 #[error("Connection is poisoned: {0}")]
43 Poisoned(Arc<RpcError>),
44
45 #[error(
46 "Data left at the end of the message. Got {message_size} bytes but only read {read} bytes. api_key={api_key:?} api_version={api_version}"
47 )]
48 TooMuchData {
49 message_size: u64,
50 read: u64,
51 api_key: ApiKey,
52 api_version: ApiVersion,
53 },
54}