formats/error.rs
1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug)]
5pub struct IOError {
6 details: String,
7}
8
9impl IOError {
10 pub fn new(msg: &str) -> IOError {
11 IOError {
12 details: msg.to_string(),
13 }
14 }
15}
16
17impl fmt::Display for IOError {
18 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19 write!(f, "{}", self.details)
20 }
21}
22
23impl Error for IOError {
24 fn description(&self) -> &str {
25 &self.details
26 }
27}