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
use sea_orm::error::DbErr;

use thiserror::Error;

use crate::app_ui::async_task_channel::*;
use crate::app_ui::event::Event;

#[derive(Error, Debug)]
pub enum LcAppError {
    #[error("Send error to reciever at sync context")]
    SyncSendError(#[from] std::sync::mpsc::SendError<Event>),

    #[error("Receive error in sync context")]
    SyncReceiveError(#[from] std::sync::mpsc::RecvError),

    #[error("Task request send error sync to async context: {0}")]
    RequestSendError(#[from] Box<RequestSendError>),

    #[error("Task request receive error sync to async context: {0}")]
    RequestRecvError(#[from] RequestRecvError),

    #[error("Cannot send one shot signal to stop looking for events. {0}")]
    StopEventsSignalSendError(String),

    #[error("Deserialization/serialization failed: {0}")]
    DeserializeError(#[from] serde_json::Error),

    #[error("Network request error.")]
    RequestError(#[from] reqwest::Error),

    #[error("IO Error")]
    IOError(#[from] std::io::Error),

    #[error("Crossterm Error {0}")]
    CrossTermError(String),

    #[error("Database Error encountered {0}")]
    DatabaseError(#[from] DbErr),

    #[cfg(target_family = "unix")]
    #[error("Maybe could not find xdg dirs {0}")]
    XDGError(#[from] xdg::BaseDirectoriesError),

    #[error("Toml parsing error")]
    TOMLParseError(#[from] toml::de::Error),

    #[error("Toml serialization error")]
    TOMLSerializeError(#[from] toml::ser::Error),

    #[error("Error while building reqwest client: {0}")]
    ClientBuildError(#[from] reqwest::header::InvalidHeaderValue),

    #[error("Tokio join handle error")]
    TokioThreadJoinError(#[from] tokio::task::JoinError),

    #[error("Key Combination already exists")]
    KeyCombiExist(String),

    #[error("Editor open error: {0}")]
    EditorOpen(String),

    #[error("unknown lc app error")]
    Unknown,
}

pub type AppResult<T> = Result<T, LcAppError>;