reshaderlib/
prelude.rs

1#[derive(thiserror::Error, Debug)]
2/// Errors that can occur when installing ReShade
3pub enum ReShaderError {
4    #[error("Unable to fetch latest ReShade version: {0}")]
5    /// Occurs when there is a problem fetching the latest ReShade version from GitHub
6    ///
7    /// For example, if the GitHub API is down, this error will occur.
8    FetchLatestVersion(String),
9
10    #[error("Unable to download {0}: {1}")]
11    /// Occurs when there is a problem downloading a file
12    ///
13    /// Additionally, the second argument is additional information about the error.
14    Download(String, String),
15
16    #[error("Could not symlink {0} to {1}: {2}")]
17    /// Occurs when there is a problem symlinking a file or a directory
18    Symlink(String, String, String),
19
20    #[error("ReShade installer had no zip file")]
21    /// Occurs when the ReShade installer doesn't have a zip file (it's missing its byte sequence for the zip file)
22    NoZipFile,
23
24    #[error("ReShade64.dll not found in ReShade installer")]
25    /// Occurs when the ReShade installer doesn't have a ReShade64.dll file contained in it
26    NoReShade64Dll,
27
28    #[error("Unable to read zip file")]
29    /// Occurs when the ReShade installer's zip file cannot be read
30    ReadZipFile,
31    #[error("Unable to extract zip file")]
32    /// Occurs when the ReShade installer's zip file cannot be extracted
33    ExtractZipFile,
34
35    #[error("Could not find repository for {0}")]
36    /// Occurs when the repository for shaders or presets cannot be found
37    RepositoryNotFound(String),
38    #[error("Could not find branch {0} for repository {1}")]
39    /// Occurs when the branch for shaders or presets cannot be found
40    BranchNotFound(String, String),
41    #[error("Merge conflicts found for branch {0} of repository {1}")]
42    /// Occurs when the branch for shaders or presets cannot be merged
43    MergeConflict(String, String),
44
45    #[error(transparent)]
46    /// Forwards the errors from `std::io::Error`
47    Io(#[from] std::io::Error),
48
49    #[error(transparent)]
50    /// Forwards the errors from `reqwest::Error`
51    Reqwest(#[from] reqwest::Error),
52
53    #[error(transparent)]
54    /// Forwards the errors from `git2::Error`
55    Git(#[from] git2::Error),
56}
57
58impl From<ReShaderError> for inquire::InquireError {
59    fn from(value: ReShaderError) -> Self {
60        inquire::InquireError::Custom(Box::new(value))
61    }
62}
63
64/// A type alias for `Result<T, ReShaderError>`
65pub type ReShaderResult<T> = std::result::Result<T, ReShaderError>;