Skip to main content

lighty_launch/
errors.rs

1use thiserror::Error;
2
3/// Errors raised by the installer pipeline.
4#[derive(Debug, Error)]
5pub enum InstallerError {
6    #[error("IO error: {0}")]
7    Io(#[from] std::io::Error),
8
9    #[error("HTTP error: {0}")]
10    Http(#[from] reqwest::Error),
11
12    #[error("SHA1 verification failed: {0}")]
13    Sha1(#[from] lighty_core::HashError),
14
15    #[error("Query error: {0}")]
16    Query(#[from] lighty_core::QueryError),
17
18    #[error("Invalid metadata: expected Version")]
19    InvalidMetadata,
20
21    #[error("Missing required field: {0}")]
22    MissingField(String),
23
24    #[error("HTTP {status} for {url}")]
25    HttpStatus { status: u16, url: String },
26
27    #[error("SHA1 mismatch for {url}: expected {expected}, got {actual}")]
28    Sha1Mismatch {
29        url: String,
30        expected: String,
31        actual: String,
32    },
33
34    #[error("Partial file for {url} is longer than the file itself")]
35    StalePartialFile { url: String },
36
37    #[error("Download of {url} failed after {attempts} attempts")]
38    RetriesExhausted { attempts: u32, url: String },
39
40    #[error("Download concurrency semaphore closed")]
41    ConcurrencyClosed,
42
43    #[error("Zip error: {0}")]
44    Zip(#[from] async_zip::error::ZipError),
45
46    #[error("JRE download failed: {0}")]
47    Jre(#[from] lighty_java::JreError),
48
49    #[error("Launch failed: {0}")]
50    JavaRuntime(#[from] lighty_java::JavaRuntimeError),
51
52    #[error("Modpack archive download failed: {0}")]
53    ModpackArchive(#[from] lighty_core::errors::DownloadError),
54
55    #[error("Unable to get process ID from child process")]
56    NoPid,
57}
58
59pub type InstallerResult<T> = std::result::Result<T, InstallerError>;