Skip to content

Commit de368e9

Browse files
CosmicHorrorDevdjc
authored andcommitted
refactor: replace thiserror with a manual impl
1 parent 6244c77 commit de368e9

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ tempfile = { version = "3", optional = true }
3030
zeroize = { version = "1.1.1", optional = true }
3131
fuzzy-matcher = { version = "0.3.7", optional = true }
3232
shell-words = "1.1.0"
33-
thiserror = "1.0.40"
3433

3534
[[example]]
3635
name = "password"

src/error.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
use std::{io::Error as IoError, result::Result as StdResult};
2-
3-
use thiserror::Error;
1+
use std::{fmt, io::Error as IoError, result::Result as StdResult};
42

53
/// Possible errors returned by prompts.
6-
#[derive(Error, Debug)]
4+
#[derive(Debug)]
75
pub enum Error {
86
/// Error while executing IO operations.
9-
#[error("IO error: {0}")]
10-
IO(#[from] IoError),
7+
IO(IoError),
8+
}
9+
10+
impl fmt::Display for Error {
11+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12+
match self {
13+
Self::IO(io) => write!(f, "IO error: {}", io),
14+
}
15+
}
16+
}
17+
18+
impl std::error::Error for Error {}
19+
20+
impl From<IoError> for Error {
21+
fn from(err: IoError) -> Self {
22+
Self::IO(err)
23+
}
1124
}
1225

1326
/// Result type where errors are of type [Error](enum@Error).

0 commit comments

Comments
 (0)