@@ -1,29 +1,7 @@ |
|
|
1 |
|
-use std::error::Error; |
2 |
|
-use std::fmt; |
3 |
|
- |
4 |
1 |
use crate::Command; |
5 |
2 |
|
6 |
3 |
#[derive(Debug)] |
7 |
|
-pub enum CkError { |
8 |
|
-/// A check failed. File didn't exist or failed to match the command |
9 |
|
- FailedCheck(String, Command), |
10 |
|
-/// An error triggered by some other error |
11 |
|
- Induced(Box<dyn Error>), |
12 |
|
-} |
13 |
|
- |
14 |
|
-impl fmt::Display for CkError { |
15 |
|
-fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
16 |
|
-match self { |
17 |
|
-CkError::FailedCheck(msg, cmd) => { |
18 |
|
-write!(f, "Failed check: {} on line {}", msg, cmd.lineno) |
19 |
|
-} |
20 |
|
-CkError::Induced(err) => write!(f, "Check failed: {}", err), |
21 |
|
-} |
22 |
|
-} |
23 |
|
-} |
24 |
|
- |
25 |
|
-impl<T: Error + 'static> From<T> for CkError { |
26 |
|
-fn from(err: T) -> CkError { |
27 |
|
-CkError::Induced(Box::new(err)) |
28 |
|
-} |
|
4 |
+pub struct CkError { |
|
5 |
+pub message: String, |
|
6 |
+pub command: Command, |
29 |
7 |
} |