diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-12-14 16:55:26 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-12-14 16:58:41 -0500 |
commit | b909e76e10695a869313c549753326d6831e2051 (patch) | |
tree | 1969568046ed19b42920c9bad7cb44e28ed79dc9 | |
parent | a64ff2d9f5e3ff26910ae7cebb857deeb11d1def (diff) | |
download | textmode-b909e76e10695a869313c549753326d6831e2051.tar.gz textmode-b909e76e10695a869313c549753326d6831e2051.zip |
drop thiserror dep
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/error.rs | 29 |
2 files changed, 22 insertions, 8 deletions
@@ -15,7 +15,6 @@ license = "MIT" itoa = "0.4.8" nix = "0.23.0" terminal_size = "0.1.17" -thiserror = "1.0.30" vt100 = "0.14.0" blocking = { version = "1.1.0", optional = true } diff --git a/src/error.rs b/src/error.rs index 90c6786..f87cead 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,18 +1,33 @@ /// Type for errors returned by this crate. -#[derive(thiserror::Error, Debug)] +#[derive(Debug)] pub enum Error { /// error reading from stdin - #[error("error reading from stdin")] - ReadStdin(#[source] std::io::Error), + ReadStdin(std::io::Error), /// error setting terminal mode - #[error("error setting terminal mode")] - SetTerminalMode(#[source] nix::Error), + SetTerminalMode(nix::Error), /// error writing to stdout - #[error("error writing to stdout")] - WriteStdout(#[source] std::io::Error), + WriteStdout(std::io::Error), } +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::ReadStdin(e) => { + write!(f, "error reading from stdin: {}", e) + } + Self::SetTerminalMode(e) => { + write!(f, "error setting terminal mode: {}", e) + } + Self::WriteStdout(e) => { + write!(f, "error writing to stdout: {}", e) + } + } + } +} + +impl std::error::Error for Error {} + /// Convenience wrapper for a `Result` using `textmode::Error`. pub type Result<T> = std::result::Result<T, Error>; |