Skip to main content

fungus/errors/
os_error.rs

1use std::{error::Error as StdError, fmt};
2
3// An error indicating that something went wrong with an os operation
4#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum OsError {
6    /// An error indicating that the kernel release was not found.
7    KernelReleaseNotFound,
8
9    /// An error indicating that the kernel version was not found.
10    KernelVersionNotFound,
11}
12
13impl StdError for OsError {}
14
15impl fmt::Display for OsError {
16    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17        match *self {
18            OsError::KernelReleaseNotFound => write!(f, "kernel release was not found"),
19            OsError::KernelVersionNotFound => write!(f, "kernel version was not found"),
20        }
21    }
22}
23
24#[cfg(test)]
25mod tests {
26    use crate::prelude::*;
27
28    #[test]
29    fn test_errors() {
30        assert_eq!(format!("{}", OsError::KernelReleaseNotFound), "kernel release was not found");
31        assert_eq!(format!("{}", OsError::KernelVersionNotFound), "kernel version was not found");
32    }
33}