From 9611b995712b33dd1d77e768a93c1cfd7ca36116 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 2 Aug 2023 05:50:59 +0200 Subject: Remove the error module and use cerm Fuck proxit, all my homies hate proxit. --- src/error.rs | 63 ------------------------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 src/error.rs (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs deleted file mode 100644 index e592e50..0000000 --- a/src/error.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::{ - env, - ffi::OsString, - fmt::{self, Display, Formatter}, - io, - path::PathBuf, -}; - -pub enum Error { - BadArgs(Option), - BadDecoding(String), - BadLengths, - DuplicateInput(PathBuf), - DuplicateOutput(PathBuf), - IO(io::Error), - Nop, - SpawnFailed(OsString, io::Error), -} - -impl Display for Error { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - let p = env::args().next().unwrap(); - match self { - Self::BadArgs(o) => { - if let Some(v) = o { - writeln!(f, "{p}: {v}")?; - } - writeln!(f, "Usage: {p} [-0eiv] command [argument ...]") - } - Self::BadDecoding(s) => writeln!(f, "{p}: Decoding the file “{s}” failed!"), - Self::BadLengths => writeln!(f, "{p}: Files have been added or removed during editing"), - Self::DuplicateInput(s) => writeln!( - f, - "{p}: Input file “{}” specified more than once", - s.to_string_lossy() - ), - Self::DuplicateOutput(s) => writeln!( - f, - "{p}: Output file “{}” specified more than once", - s.to_string_lossy() - ), - Self::IO(e) => writeln!(f, "{p}: {e}"), - Self::Nop => Ok(()), - Self::SpawnFailed(ed, e) => writeln!( - f, - "{p}: Failed to spawn utility “{}”: {e}", - ed.to_string_lossy() - ), - } - } -} - -impl From for Error { - fn from(e: io::Error) -> Self { - Self::IO(e) - } -} - -impl From for Error { - fn from(e: lexopt::Error) -> Self { - Self::BadArgs(Some(e)) - } -} -- cgit v1.2.3