Skip to main content

valheim_mod_manager/
error.rs

1use std::io;
2use std::num::ParseIntError;
3use thiserror::Error;
4
5/// A type alias for `Result<T, AppError>`.
6pub type AppResult<T> = Result<T, AppError>;
7
8/// Represents all possible errors that can occur in the application.
9#[derive(Error, Debug)]
10pub enum AppError {
11  /// Error from the IO system.
12  #[error("IO error: {0}")]
13  Io(#[from] io::Error),
14
15  /// Error from HTTP operations.
16  #[error("HTTP error: {0}")]
17  Http(#[from] reqwest::Error),
18
19  /// Error from JSON parsing.
20  #[error("JSON error: {0}")]
21  Json(#[from] serde_json::Error),
22
23  /// Error from ZIP operations.
24  #[error("ZIP error: {0}")]
25  Zip(#[from] zip::result::ZipError),
26
27  /// Error from date/time parsing.
28  #[error("DateTime parse error: {0}")]
29  DateTime(#[from] chrono::ParseError),
30
31  /// Error from header parsing.
32  #[error("Header error: {0}")]
33  Header(#[from] reqwest::header::ToStrError),
34
35  /// Error from parsing integers.
36  #[error("Parse integer error: {0}")]
37  ParseInt(#[from] ParseIntError),
38
39  /// Missing header in response.
40  #[error("Missing header: {0}")]
41  MissingHeader(String),
42
43  /// Error from manifest parsing.
44  #[error("Manifest error: {0}")]
45  Manifest(String),
46
47  /// Generic application error.
48  #[error("{0}")]
49  Other(String),
50
51  /// Error when a task fails.
52  #[error("Task failed: {0}")]
53  TaskFailed(#[from] tokio::task::JoinError),
54
55  /// Error when serializing a config fails.
56  #[error("Config serialization error: {0}")]
57  ConfigSerialization(String),
58}