| 1 | use std::num::TryFromIntError; |
| 2 | use std::sync::Arc; |
| 3 | |
| 4 | #[derive(Debug, Clone, thiserror::Error)] |
| 5 | #[non_exhaustive] |
| 6 | pub enum Error { |
| 7 | #[error("Remote error: {0}")] |
| 8 | Io(Arc<std::io::Error>), |
| 9 | #[error("OutOfMemory")] |
| 10 | OutOfMemory, |
| 11 | #[error("TryFromIntError")] |
| 12 | TryFromIntError(#[from] TryFromIntError), |
| 13 | } |
| 14 | |
| 15 | impl From<std::io::Error> for Error { |
| 16 | fn from(err: std::io::Error) -> Self { |
| 17 | if err.kind() == std::io::ErrorKind::OutOfMemory { |
| 18 | Self::OutOfMemory |
| 19 | } else { |
| 20 | Self::Io(Arc::new(err)) |
| 21 | } |
| 22 | } |
| 23 | } |