1use std::io;
4
5use thiserror::Error;
6
7pub type Result<T> = std::result::Result<T, RomError>;
9
10#[derive(Debug, Error)]
12pub enum RomError {
13 #[error("IO error: {0}")]
15 Io(#[from] io::Error),
16
17 #[error("JSON parsing error: {0}")]
19 Json(#[from] serde_json::Error),
20
21 #[error("Build failed")]
23 BuildFailed,
24
25 #[error("Process error: {0}")]
27 Process(String),
28
29 #[error("Configuration error: {0}")]
31 Config(String),
32
33 #[error("Parse error: {0}")]
35 Parse(String),
36
37 #[error("Terminal error: {0}")]
39 Terminal(String),
40
41 #[error("{0}")]
43 Other(String),
44}
45
46impl RomError {
47 pub fn process<S: Into<String>>(msg: S) -> Self {
49 Self::Process(msg.into())
50 }
51
52 pub fn config<S: Into<String>>(msg: S) -> Self {
54 Self::Config(msg.into())
55 }
56
57 pub fn parse<S: Into<String>>(msg: S) -> Self {
59 Self::Parse(msg.into())
60 }
61
62 pub fn terminal<S: Into<String>>(msg: S) -> Self {
64 Self::Terminal(msg.into())
65 }
66
67 pub fn other<S: Into<String>>(msg: S) -> Self {
69 Self::Other(msg.into())
70 }
71}