aboutsummaryrefslogtreecommitdiffstats
path: root/src/error.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-03 19:43:06 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-03 19:43:06 -0500
commit8a98d4fee2172d5ac53e74bcc95cd39aa68492a3 (patch)
tree10fb97bbd275fc1ea6a1e69300e7ba1bc1e35430 /src/error.rs
parent22b2262bdc097ac6ddbe4c7ce488b1afb4f9127e (diff)
downloadttyrec-8a98d4fee2172d5ac53e74bcc95cd39aa68492a3.tar.gz
ttyrec-8a98d4fee2172d5ac53e74bcc95cd39aa68492a3.zip
remove async stuff, clean up everything else
will reintroduce the async stuff in a future commit
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/error.rs b/src/error.rs
index c106d02..9ca35a8 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,30 +1,24 @@
/// Errors potentially returned by this crate.
-#[derive(Debug, snafu::Snafu)]
-#[snafu(visibility(pub))]
+#[derive(Debug)]
pub enum Error {
- /// eof
- #[snafu(display("eof"))]
- EOF,
-
/// failed to create ttyrec frame: got N bytes of data but ttyrec frames
/// can be at most M bytes
- #[snafu(display("failed to create ttyrec frame: got {} bytes of data, but ttyrec frames can be at most {} bytes", input, u32::max_value()))]
FrameTooBig { input: usize },
/// failed to create ttyrec frame: got N seconds but ttyrec frames can be
/// at most M seconds
- #[snafu(display("failed to create ttyrec frame: got {} seconds, but ttyrecs can be at most {} seconds", input, u32::max_value()))]
FrameTooLong { input: u64 },
+}
- /// failed to read from file
- #[cfg(feature = "async")]
- #[snafu(display("failed to read from file: {}", source))]
- ReadFile { source: tokio::io::Error },
-
- /// failed to write to file
- #[cfg(feature = "async")]
- #[snafu(display("failed to write to file: {}", source))]
- WriteFile { source: tokio::io::Error },
+impl std::fmt::Display for Error {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ Self::FrameTooBig { input } => write!(f, "failed to create ttyrec frame: got {} bytes of data, but ttyrec frames can be at most {} bytes", input, u32::max_value()),
+ Self::FrameTooLong { input } => write!(f, "failed to create ttyrec frame: got {} seconds, but ttyrecs can be at most {} seconds", input, u32::max_value()),
+ }
+ }
}
+impl std::error::Error for Error {}
+
pub type Result<T> = std::result::Result<T, Error>;