Skip to main content

x86/
error.rs

1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
4pub enum X86Error {
5    #[error("I/O error while accessing {path}: {source}")]
6    Io {
7        path: PathBuf,
8        #[source]
9        source: std::io::Error,
10    },
11    #[error("invalid image: {0}")]
12    InvalidImage(String),
13    #[error("invalid saved state: {0}")]
14    InvalidState(String),
15    #[error("unsupported format: {0}")]
16    UnsupportedFormat(String),
17    #[error("remote loading is disabled; enable the `remote` feature")]
18    RemoteDisabled,
19    #[error("remote request failed for {url}: {message}")]
20    Remote { url: String, message: String },
21    #[error("serialization error: {0}")]
22    Serialization(#[from] serde_json::Error),
23    #[error("operation is not available in the current backend: {0}")]
24    BackendUnavailable(String),
25}
26
27pub type Result<T> = std::result::Result<T, X86Error>;
28
29pub(crate) fn io_error(path: impl Into<PathBuf>, source: std::io::Error) -> X86Error {
30    X86Error::Io {
31        path: path.into(),
32        source,
33    }
34}