fungus/errors/
string_error.rs

1use std::{error::Error as StdError, fmt};
2
3// An error indicating that something went wrong with a file operation
4#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum StringError {
6    /// An error indicating a failure to convert the file value to a string.
7    FailedToString,
8}
9
10impl StdError for StringError {}
11
12impl fmt::Display for StringError {
13    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14        match *self {
15            StringError::FailedToString => write!(f, "failed to convert value to string"),
16        }
17    }
18}
19
20#[cfg(test)]
21mod tests {
22    use crate::errors::*;
23
24    #[test]
25    fn test_errors() {
26        assert_eq!(format!("{}", StringError::FailedToString), "failed to convert value to string");
27    }
28}