loadsmith_loader/error.rs
1use camino::Utf8PathBuf;
2
3/// Errors that can occur during loader setup and launch-argument generation.
4///
5/// # Examples
6///
7/// ```rust
8/// use loadsmith_loader::Error;
9///
10/// let err = Error::UnsupportedDoorstopVersion(5);
11/// assert_eq!(err.to_string(), "unsupported doorstop version: 5");
12/// ```
13#[derive(Debug, thiserror::Error)]
14pub enum Error {
15 /// An I/O error occurred.
16 #[error("I/O error")]
17 Io(#[from] std::io::Error),
18
19 /// The `.doorstop_version` file contains an unparseable value.
20 #[error("invalid doorstop version format: {0}")]
21 InvalidDoorstopVersionFormat(String),
22
23 /// A Doorstop version other than 3 or 4 was requested.
24 #[error("unsupported doorstop version: {0}")]
25 UnsupportedDoorstopVersion(u32),
26
27 /// The BepInEx core directory could not be opened.
28 #[error("BepInEx core directory is missing")]
29 BepInExCoreDirectoryMissing {
30 #[source]
31 source: std::io::Error,
32 },
33
34 /// The BepInEx preloader assembly was not found in the core directory.
35 #[error("BepInEx preloader not found in core directory at {core_directory}")]
36 BepInExPreloaderNotFound { core_directory: Utf8PathBuf },
37}
38
39/// Convenience alias for `Result<T, loadsmith_loader::Error>`.
40pub type Result<T> = std::result::Result<T, Error>;