yocto/
error.rs

1//
2// (c) 2019 Alexander Becker
3// Released under the MIT license.
4//
5
6use std::{fmt, error};
7
8#[derive(Debug, Clone)]
9pub struct ParseError;
10
11impl fmt::Display for ParseError {
12    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13        write!(f, "Unable to parse command")
14    }
15}
16
17impl error::Error for ParseError {
18    fn description(&self) -> &str {
19        "Unable to parse command"
20    }
21
22    fn cause(&self) -> Option<&error::Error> {
23        None
24    }
25}
26
27#[derive(Debug, Clone)]
28pub struct StorageError(pub String);
29
30impl fmt::Display for StorageError {
31    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
32        write!(f, "{}", self.0)
33    }
34}
35
36impl error::Error for StorageError {
37    fn description(&self) -> &str {
38        self.0.as_ref()
39    }
40
41    fn cause(&self) -> Option<&error::Error> {
42        None
43    }
44}