use std::io;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, RomError>;
#[derive(Debug, Error)]
pub enum RomError {
#[error("IO error: {0}")]
Io(#[from] io::Error),
#[error("JSON parsing error: {0}")]
Json(#[from] serde_json::Error),
#[error("Build failed")]
BuildFailed,
#[error("Process error: {0}")]
Process(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Parse error: {0}")]
Parse(String),
#[error("Terminal error: {0}")]
Terminal(String),
#[error("{0}")]
Other(String),
}
impl RomError {
pub fn process<S: Into<String>>(msg: S) -> Self {
Self::Process(msg.into())
}
pub fn config<S: Into<String>>(msg: S) -> Self {
Self::Config(msg.into())
}
pub fn parse<S: Into<String>>(msg: S) -> Self {
Self::Parse(msg.into())
}
pub fn terminal<S: Into<String>>(msg: S) -> Self {
Self::Terminal(msg.into())
}
pub fn other<S: Into<String>>(msg: S) -> Self {
Self::Other(msg.into())
}
}