use std::path::PathBuf;
use std::process::ExitStatus;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("no input .rdl files provided")]
NoInputs,
#[error(
"no output directory provided and $OUT_DIR is not set; are you calling this from a build.rs?"
)]
NoOutDir,
#[error("no top-level addrmap specified")]
NoTop,
#[error(
"could not determine a cache directory; set PEAKRDL_RUST_BINARY to a path to the generator binary"
)]
NoCacheDir,
#[error(
"unsupported platform: {os}-{arch}; open an issue to request support: https://github.com/darsor/PeakRDL-rust/issues"
)]
UnsupportedPlatform { os: String, arch: String },
#[error("failed to download generator binary from {url}: {reason}")]
DownloadFailed { url: String, reason: String },
#[error("generator binary checksum mismatch: expected {expected}, got {actual}")]
ChecksumMismatch { expected: String, actual: String },
#[error("failed to spawn {}: {source}", binary.display())]
SpawnFailed {
binary: PathBuf,
#[source]
source: std::io::Error,
},
#[error("peakrdl-rust exited with {status}\nstdout:\n{stdout}\nstderr:\n{stderr}")]
GeneratorFailed {
status: ExitStatus,
stdout: String,
stderr: String,
},
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}