| 1 | pub type Result<T> = std::result::Result<T, Error>; |
| 2 | |
| 3 | #[derive(Debug, thiserror::Error)] |
| 4 | pub enum Error { |
| 5 | #[error(transparent)] |
| 6 | Graph(#[from] graph::Error), |
| 7 | #[error(transparent)] |
| 8 | Store(#[from] store::Error), |
| 9 | #[error("cannot write the file: {0}")] |
| 10 | Io(#[from] std::io::Error), |
| 11 | #[error("folder service: {0}")] |
| 12 | Folders(String), |
| 13 | #[error("unknown conversation {0}")] |
| 14 | UnknownConversation(String), |
| 15 | #[error("GIFs are disabled by the organization")] |
| 16 | GifsDisabled, |
| 17 | #[error("{0} is not supported yet")] |
| 18 | Unsupported(&'static str), |
| 19 | } |
| 20 | |
| 21 | impl From<chatsvc::Error> for Error { |
| 22 | fn from(error: chatsvc::Error) -> Self { |
| 23 | match error { |
| 24 | chatsvc::Error::Session(inner) => Error::Graph(graph::Error::Session(inner)), |
| 25 | chatsvc::Error::GifsDisabled => Error::GifsDisabled, |
| 26 | other => Error::Folders(other.to_string()), |
| 27 | } |
| 28 | } |
| 29 | } |