Skip to main content

conduit_cli/
errors.rs

1use std::io;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum ConduitError {
6    #[error("io error: {0}")]
7    Io(#[from] io::Error),
8
9    #[error("disk space or permission error: {0}")]
10    Storage(String),
11
12    #[error("network request failed: {0}")]
13    Network(#[from] reqwest::Error),
14
15    #[error("failed to download resource from {0}")]
16    DownloadFailed(String),
17
18    #[error("api returned an error: {0}")]
19    ApiFailure(String),
20
21    #[error("failed to deserialize response: {0}")]
22    Deserialize(String),
23
24    #[error("hash mismatch: expected {expected}, got {actual}")]
25    HashMismatch { expected: String, actual: String },
26
27    #[error("migration failed: {0}")]
28    Migration(String),
29
30    #[error("failed to parse configuration: {0}")]
31    Config(#[from] toml::de::Error),
32
33    #[error("failed to save configuration: {0}")]
34    SaveConfig(#[from] toml::ser::Error),
35
36    #[error("unsupported loader or version: {0}")]
37    Unsupported(String),
38
39    #[error("couldn't launch loader, please install it first")]
40    NotInstalled,
41
42    #[error("could not find a valid entry point (server.jar or args file)")]
43    NoEntryPoint,
44
45    #[error("resource not found: {0}")]
46    NotFound(String),
47
48    #[error("Project already initialized: {0}")]
49    AlreadyInitialized(String),
50
51    #[error("Validation failed: {0}")]
52    Validation(String),
53}
54
55pub type ConduitResult<T> = Result<T, ConduitError>;