pop3_client/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Pop3Error {
5    #[error("Stream connection closed")]
6    ConnectionClosed,
7
8    #[error("Already authenticated")]
9    AlreadyAuthenticated,
10
11    #[error("IO: {0}")]
12    Io(#[from] std::io::Error),
13
14
15    #[error("Number parsing error: {0}")]
16    InvalidNumber(std::num::ParseIntError),
17
18    #[error("String parsing error: {0}")]
19    InvalidString(std::str::Utf8Error),
20
21    #[error("Invalid response")]
22    InvalidResponse,
23
24    #[error("Other error: {0}")]
25    OtherString(String),
26
27    // #[error("invalid header (expected {expected:?}, found {found:?})")]
28    // InvalidHeader {
29    //     expected: String,
30    //     found: String,
31    // },
32    // #[error("unknown data store error")]
33    // Unknown,
34}
35
36impl Pop3Error {
37    pub fn other<E: AsRef<str>>(err: E) -> Self {
38        Self::OtherString(err.as_ref().to_string())
39    }
40}