1use std::error::Error;
5use std::fmt;
6
7#[derive(Debug)]
9pub struct EthtoolError {
10 details: String,
11}
12
13impl EthtoolError {
14 pub fn new(msg: &str) -> EthtoolError {
15 EthtoolError {
16 details: msg.to_string(),
17 }
18 }
19}
20
21impl fmt::Display for EthtoolError {
22 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23 write!(f, "{}", self.details)
24 }
25}
26
27impl Error for EthtoolError {}
28
29#[cfg(test)]
30mod test {
31 #[test]
32 fn test_errors() {
33 use super::EthtoolError;
34 let err = EthtoolError::new("test");
35 format!("{:?}", err);
36 assert_eq!(err.to_string(), "test");
37 }
38}