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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
use thiserror::Error;
use crate::date;
#[derive(Error, Debug, PartialEq)]
pub enum PathError {
#[error("Error accessing file '{0}': {1}")]
FileAccess(String, String),
#[error("Error writing to file '{0}': {1}")]
FileWrite(String, String),
#[error("Required filename not supplied")]
FilenameMissing,
#[error("Missing directory '{0}': {1}")]
InvalidPath(String, String),
#[error("Logfiles path contains invalid characters")]
InvalidTimelogPath,
#[error("Config path contains invalid characters")]
InvalidConfigPath,
#[error("Cannot overwrite, '{0}' already exists")]
AlreadyExists(String),
#[error("Cannot rename '{0}': {1}")]
RenameFailure(String, String),
#[error("Cannot create path '{0}': {1}")]
CantCreatePath(String, String),
#[error("Cannot read timelog")]
CantReadTimelog,
#[error("Cannot write report file")]
CantWriteReport,
}
#[derive(Error, Debug, PartialEq)]
pub enum Error {
#[error(transparent)]
InvalidEntryLine {
#[from]
source: crate::entry::EntryError,
},
#[error("Missing required stamp.")]
MissingDate,
#[error("Invalid starting date.")]
StartDateFormat,
#[error("Invalid ending date.")]
EndDateFormat,
#[error("Start date after end date.")]
WrongDateOrder,
#[error("Unable to pop stack item")]
StackPop,
#[error("Invalid drop argument '{0}'")]
InvalidDrop(String),
#[error("Invalid pos integer argument '{0}'")]
InvalidInt(String),
#[error("Bad project filters")]
BadProjectFilter,
#[error("'{0}' is not a valid command")]
InvalidCommand(String),
#[error("Deprecated! Use '{0}' instead.")]
DeprecatedCommand(&'static str),
#[error("Editor '{0}' failed to execute: {1}")]
EditorFailed(String, String),
#[error("Argument '{0}' is unexpected")]
UnexpectedArgument(String),
#[error(transparent)]
DateError {
#[from]
source: date::Error,
},
#[error(transparent)]
PathError {
#[from]
source: PathError,
},
}
impl From<xml::writer::Error> for Error {
fn from(_e: xml::writer::Error) -> Error { PathError::CantWriteReport.into() }
}