shoal_core/server/
errors.rs1use glommio::GlommioError;
4use glommio::{BuilderErrorKind, ExecutorErrorKind, ReactorErrorKind};
5use std::os::fd::RawFd;
6use std::path::PathBuf;
7use std::time::Duration;
8
9#[derive(Debug)]
11pub enum ServerError {
12 Shoal(ShoalError),
14 IO(std::io::Error),
16 GlommioIO {
18 source: std::io::Error,
19 op: &'static str,
20 path: Option<PathBuf>,
21 fd: Option<RawFd>,
22 },
23 GlommioExectorError(ExecutorErrorKind),
25 GlommioBuilderError(BuilderErrorKind),
27 GlommioReactorError(ReactorErrorKind),
29 GlommioTimedOut(Duration),
31 GlommioGeneric(String),
33 Config(config::ConfigError),
35 Rkyv(rkyv::rancor::Error),
37 IntoSlice(std::array::TryFromSliceError),
39 Conversion(std::convert::Infallible),
41 KanalSend(kanal::SendError),
43 KanalRecv(kanal::ReceiveError),
45}
46
47impl<T> From<glommio::GlommioError<T>> for ServerError {
49 fn from(ext: glommio::GlommioError<T>) -> Self {
50 match ext {
51 GlommioError::IoError(error) => Self::IO(error),
52 GlommioError::EnhancedIoError {
53 source,
54 op,
55 path,
56 fd,
57 } => Self::GlommioIO {
58 source,
59 op,
60 path,
61 fd,
62 },
63 GlommioError::ExecutorError(error) => Self::GlommioExectorError(error),
64 GlommioError::BuilderError(error) => Self::GlommioBuilderError(error),
65 GlommioError::ReactorError(error) => Self::GlommioReactorError(error),
66 GlommioError::TimedOut(duration) => Self::GlommioTimedOut(duration),
67 GlommioError::Closed(_) => Self::GlommioGeneric(ext.to_string()),
68 GlommioError::CanNotBeClosed(_, _) => Self::GlommioGeneric(ext.to_string()),
69 GlommioError::WouldBlock(_) => Self::GlommioGeneric(ext.to_string()),
70 }
71 }
72}
73
74impl From<config::ConfigError> for ServerError {
75 fn from(error: config::ConfigError) -> Self {
81 ServerError::Config(error)
82 }
83}
84
85impl From<std::io::Error> for ServerError {
86 fn from(error: std::io::Error) -> Self {
92 ServerError::IO(error)
93 }
94}
95
96impl From<rkyv::rancor::Error> for ServerError {
97 fn from(error: rkyv::rancor::Error) -> Self {
103 ServerError::Rkyv(error)
104 }
105}
106
107impl From<std::array::TryFromSliceError> for ServerError {
108 fn from(error: std::array::TryFromSliceError) -> Self {
114 ServerError::IntoSlice(error)
115 }
116}
117
118impl From<std::convert::Infallible> for ServerError {
119 fn from(error: std::convert::Infallible) -> Self {
125 ServerError::Conversion(error)
126 }
127}
128
129impl From<kanal::SendError> for ServerError {
130 fn from(error: kanal::SendError) -> Self {
136 ServerError::KanalSend(error)
137 }
138}
139
140impl From<kanal::ReceiveError> for ServerError {
141 fn from(error: kanal::ReceiveError) -> Self {
147 ServerError::KanalRecv(error)
148 }
149}
150
151#[derive(Debug)]
153pub enum ShoalError {
154 NonBinaryMessage,
156}