1use std::io;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum GitError {
6 #[error("Error loading stdin: {0}")]
7 Io(#[from] io::Error),
8
9 #[error("Required info missing from input: {0:?}")]
10 MissingInfo(String),
11
12 #[error("Provided information invalid: {0:?}")]
13 InvalidInfo(String),
14}
15
16#[derive(Error, Debug)]
17pub enum DatabaseError {
18 #[error("Error constructing database paths")]
19 Path,
20
21 #[error("Error managing database file: {0}")]
22 Io(#[from] io::Error),
23
24 #[error("Rusqlite error: {0}")]
25 Sqlite(#[from] rusqlite::Error),
26}
27
28#[derive(Error, Debug)]
29pub enum GithubError {
30 #[error("{0}")]
31 ReqwestError(#[from] reqwest::Error),
32
33 #[error("Missing field {0} in api response")]
34 MissingField(String),
35
36 #[error("API response field {0} contained invalid or unexpected data")]
37 InvalidField(String),
38
39 #[error("Timed out waiting for authentication. Token only valif for {0}s")]
40 Timeout(i32),
41
42 #[error("Keyring failed to store token: {0}")]
43 KeyingError(#[from] keyring::Error),
44}
45
46#[derive(Error, Debug)]
47pub enum Error {
48 #[error("{0}")]
49 GithubError(#[from] GithubError),
50
51 #[error("{0}")]
52 GitError(#[from] GitError),
53
54 #[error("{0}")]
55 DatabaseError(#[from] DatabaseError),
56
57 #[error("{0}")]
58 PromptError(#[from] inquire::error::InquireError),
59}
60
61