[go: up one dir, main page]

automod/
error.rs

1use std::ffi::OsString;
2use std::fmt::{self, Display};
3use std::io;
4
5pub enum Error {
6    Io(io::Error),
7    Utf8(OsString),
8    Empty,
9}
10
11pub type Result<T> = std::result::Result<T, Error>;
12
13impl Display for Error {
14    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15        use self::Error::*;
16
17        match self {
18            Io(err) => err.fmt(f),
19            Utf8(name) => write!(
20                f,
21                "unsupported non-utf8 file name: {}",
22                name.to_string_lossy(),
23            ),
24            Empty => f.write_str("no source files found"),
25        }
26    }
27}
28
29impl From<io::Error> for Error {
30    fn from(err: io::Error) -> Self {
31        Error::Io(err)
32    }
33}