Skip to main content

cargo_move/
error.rs

1//! Error types
2
3use abscissa_core::err;
4use failure::Fail;
5use std::{fmt, io};
6
7/// Error type
8#[derive(Debug)]
9pub struct Error(abscissa_core::Error<ErrorKind>);
10
11/// Kinds of errors
12#[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)]
13pub enum ErrorKind {
14    /// Error in configuration file
15    #[fail(display = "config error")]
16    Config,
17
18    /// Input/output error
19    #[fail(display = "I/O error")]
20    Io,
21}
22
23impl fmt::Display for Error {
24    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25        self.0.fmt(f)
26    }
27}
28
29impl From<abscissa_core::Error<ErrorKind>> for Error {
30    fn from(other: abscissa_core::Error<ErrorKind>) -> Self {
31        Error(other)
32    }
33}
34
35impl From<io::Error> for Error {
36    fn from(other: io::Error) -> Self {
37        err!(ErrorKind::Io, other).into()
38    }
39}