1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use std::fmt;
use std::io;
use std::error::Error;
/// Project_cfg error
#[derive(Debug)]
pub struct TmuxInterfaceError {
/// The formatted error message
pub err_text: String,
/// The type of error
pub err_type: usize
}
impl TmuxInterfaceError {
pub fn new(error: &str) -> Self {
TmuxInterfaceError {
err_text: error.to_string(),
err_type: 0
}
}
}
impl Error for TmuxInterfaceError {
fn description(&self) -> &str {
"invalid first item to double"
}
//fn cause(&self) -> Option<&Error> {
//match self.error_type {
//_ => None,
//}
//}
}
// Implement std::convert::From for MyError; from io::Error
impl From<io::Error> for TmuxInterfaceError {
fn from(_error: io::Error) -> Self {
TmuxInterfaceError {
err_text: String::from("io"),
err_type: 1
//message: error.to_string(),
}
}
}
//
impl From<regex::Error> for TmuxInterfaceError {
fn from(_error: regex::Error) -> Self {
TmuxInterfaceError {
err_text: String::from("regex"),
err_type: 1
//message: error.to_string(),
}
}
}
impl From<std::num::ParseIntError> for TmuxInterfaceError {
fn from(_error: std::num::ParseIntError) -> Self {
TmuxInterfaceError {
err_text: String::from("parse num"),
err_type: 1
//message: error.to_string(),
}
}
}
impl From<std::string::ParseError> for TmuxInterfaceError {
fn from(_error: std::string::ParseError) -> Self {
TmuxInterfaceError {
err_text: String::from("parse string"),
err_type: 1
//message: error.to_string(),
}
}
}
//impl From<std::option::NoneError> for TmuxInterfaceError {
//fn from(_error: std::option::NoneError) -> Self {
//TmuxInterfaceError {
//err_text: String::from("parse"),
//err_type: 1
////message: error.to_string(),
//}
//}
//}
impl fmt::Display for TmuxInterfaceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.err_text)
}
}