mmv_lib/
error_handler.rs

1#![forbid(unsafe_code)]
2
3use std::io;
4
5pub enum Error {
6    InvalidDirectory(io::Error),
7    NoFilesFound,
8    NoMatchingFilesFound,
9}
10
11impl From<io::Error> for Error {
12    fn from(error: io::Error) -> Self {
13        Error::InvalidDirectory(error)
14    }
15}
16
17pub fn react_on_error(error: Error) {
18    match error {
19        Error::NoFilesFound => {
20            println!("No files found in input pattern directory");
21        }
22
23        Error::InvalidDirectory(_) => {
24            println!("Invalid input pattern directory");
25        }
26
27        Error::NoMatchingFilesFound => {
28            println!("No files found matching input pattern");
29        }
30    }
31}