diff options
| author | Igor Tolmachev <me@igorek.dev> | 2024-06-27 16:15:00 +0900 |
|---|---|---|
| committer | Igor Tolmachev <me@igorek.dev> | 2024-06-29 21:18:46 +0900 |
| commit | 51694e1f0b2730915e0a57ec6d8de503cf06ef9a (patch) | |
| tree | 165f3adbc29f96814b57aeba394fb4045af7c5f0 /src/error.rs | |
| parent | a867677218c1d55dadfcac1ca5b8cd32a78a3c28 (diff) | |
| download | archivator-51694e1f0b2730915e0a57ec6d8de503cf06ef9a.tar.gz archivator-51694e1f0b2730915e0a57ec6d8de503cf06ef9a.zip | |
Create file driver and implement file reader
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/error.rs b/src/error.rs index 7172d04..97a4e62 100644 --- a/src/error.rs +++ b/src/error.rs | |||
| @@ -6,21 +6,21 @@ pub type ArchiveResult<T, E> = Result<T, ArchiveError<E>>; | |||
| 6 | 6 | ||
| 7 | #[derive(Debug)] | 7 | #[derive(Debug)] |
| 8 | pub enum ArchiveError<E: Error> { | 8 | pub enum ArchiveError<E: Error> { |
| 9 | IO { error: io::Error }, | 9 | Io { error: io::Error }, |
| 10 | Serde { message: String }, | 10 | Serde { message: String }, |
| 11 | Archivator { module: String, error: E }, | 11 | Archivator { module: String, error: E }, |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | impl<E: Error> From<io::Error> for ArchiveError<E> { | 14 | impl<E: Error> From<io::Error> for ArchiveError<E> { |
| 15 | fn from(value: io::Error) -> Self { | 15 | fn from(value: io::Error) -> Self { |
| 16 | Self::IO { error: value } | 16 | Self::Io { error: value } |
| 17 | } | 17 | } |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | impl<E: Error> Display for ArchiveError<E> { | 20 | impl<E: Error> Display for ArchiveError<E> { |
| 21 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 21 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 22 | match self { | 22 | match self { |
| 23 | Self::IO { error } => writeln!(f, "IO: {error}"), | 23 | Self::Io { error } => writeln!(f, "IO: {error}"), |
| 24 | Self::Serde { message } => writeln!(f, "Serde: {message}"), | 24 | Self::Serde { message } => writeln!(f, "Serde: {message}"), |
| 25 | Self::Archivator { module, error } => writeln!(f, "{module}: {error}"), | 25 | Self::Archivator { module, error } => writeln!(f, "{module}: {error}"), |
| 26 | } | 26 | } |
