Skip to main content

loadsmith_platform/
error.rs

1use std::process::ExitStatus;
2
3/// Errors that can occur during platform and game detection.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// An underlying I/O error.
7    #[error("I/O error")]
8    Io(#[from] std::io::Error),
9
10    /// An error parsing or serialising JSON (e.g. Epic Games manifest).
11    #[error("JSON error")]
12    Json(#[from] serde_json::Error),
13
14    /// A path could not be converted to valid UTF-8.
15    #[error("path is not valid UTF-8")]
16    Utf8(#[from] camino::FromPathBufError),
17
18    /// An error from the steamlocate library.
19    #[error("steamlocate error")]
20    SteamLocate(#[from] steamlocate::Error),
21
22    /// The requested app ID was not found in any Steam library.
23    #[error("could not find app in steam library")]
24    SteamAppNotFound,
25
26    /// The Steam executable could not be located.
27    #[error("could not find steam executable")]
28    SteamExecutableNotFound,
29
30    /// A PowerShell query for Xbox Store games failed with a non-zero exit
31    /// status.
32    #[error("Xbox Store query failed with status {status}")]
33    XboxStoreQueryFailed { status: ExitStatus },
34
35    /// A PowerShell query for Xbox Store games returned non-UTF-8 output.
36    #[error("Xbox Store query returned non-UTF-8 output")]
37    XboxNonUtf8 {
38        #[source]
39        source: std::string::FromUtf8Error,
40    },
41
42    /// The game was not found in the Epic Games Launcher installations.
43    #[error("game not found in Epic Games Launcher installations")]
44    EpicGameNotFound,
45
46    /// The game path could not be determined and no override was provided.
47    #[error("game path could not be determined and no override was provided")]
48    NoGamePathOverride,
49}
50
51/// Alias for `Result<T, Error>` in the loadsmith-platform crate.
52pub type Result<T> = std::result::Result<T, Error>;