1use std::num::ParseIntError;
2
3use thiserror::Error;
4
5#[derive(Clone, Debug, PartialEq, Ord, PartialOrd, Eq, Hash, Error)]
6#[allow(missing_docs)]
7pub enum EslError {
9 #[error("unknown error")]
10 InternalError(String),
11
12 #[error("Wrong password.")]
13 AuthFailed,
14
15 #[error("Unable to connect to destination server.")]
16 ConnectionError(String),
17
18 #[error("{0:?}")]
19 ApiError(String),
20
21 #[error("")]
22 CodeParseError(),
23
24 #[error("Didnt get any digits")]
25 NoInput,
26}
27
28impl From<std::io::Error> for EslError {
29 fn from(error: std::io::Error) -> Self {
30 Self::InternalError(error.to_string())
31 }
32}
33impl From<tokio::sync::oneshot::error::RecvError> for EslError {
34 fn from(error: tokio::sync::oneshot::error::RecvError) -> Self {
35 Self::InternalError(error.to_string())
36 }
37}
38impl From<serde_json::Error> for EslError {
39 fn from(error: serde_json::Error) -> Self {
40 Self::InternalError(error.to_string())
41 }
42}
43impl From<ParseIntError> for EslError {
44 fn from(error: ParseIntError) -> Self {
45 Self::InternalError(error.to_string())
46 }
47}