1use super::tasklist::TaskDescription;
2
3pub(super) type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 #[error("every task should have at least one state")]
8 EveryTaskShouldHaveAtLeastOneState,
9 #[error("could not format to file name:{0}")]
10 CouldNotFormatToFileName(#[from] time::error::Format),
11 #[error("invalid time format for file name:{0}")]
12 CouldNotParseTimeFormatDescription(#[from] time::error::InvalidFormatDescription),
13 #[error("directory could not be created")]
14 DirCouldNotBeCreated(fs_extra::error::Error),
15 #[error("task with that name already exist")]
16 TaskFileAlreadyExists,
17 #[error("file could not be serialized")]
18 FileCouldNotSerializeEntryIntoJson(serde_json::Error, String),
19 #[error("could not serialize taskactionss into json {0}")]
20 FileCouldNotSerializeTaskActionsIntoJson(serde_json::Error),
21 #[error("file could not written to")]
22 FileCouldNotBeWrittenTo(fs_extra::error::Error),
23 #[error("directory could not be read")]
24 DirCouldNotBeRead(fs_extra::error::Error),
25 #[error("file cannot deserialize entry {1} from json string: {0}")]
26 FileCouldNotDeserializeEntryFromJson(serde_json::Error, String),
27 #[error("file cannot be read: {0}")]
28 FileCouldNotBeRead(fs_extra::error::Error),
29 #[error("more than one task with that ID was found: {0:?}")]
30 MoreThanOneTaskWasFound(Box<Vec<TaskDescription>>),
31 #[error("no tasks with that identifier was found")]
32 NoTasksFound,
33 #[error("got error from running git command: {0}")]
34 GitError(leafslug_effects::git::Error),
35 #[error("file name has invalid characters")]
36 FileNameHasInvalidCharacters,
37 #[error("the path is not a file")]
38 IsNotAFile,
39 #[error("something went wrong in parsing line: {0}")]
40 ParsingLineFailed(Box<String>),
41 #[error("could not run editor: {0}")]
42 FailedInRunningEditor(dialoguer::Error),
43 #[error("content of editor is empty")]
44 EmptyEditorContent,
45 #[error("effector errored: {0}")]
46 EffectorError(#[from] leafslug_effects::Error),
47}
48#[cfg(test)]
49mod testing {
50 use super::*;
51
52 const fn is_normal<T: Sized + Send + Sync + Unpin>() {}
53
54 #[test]
55 const fn normal_types() {
56 is_normal::<Error>();
57 }
58}