Move code into cli directory
This commit is contained in:
parent
b8dd5d2640
commit
5b0e12ea33
29 changed files with 32 additions and 26 deletions
24
cli/src/error.rs
Normal file
24
cli/src/error.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#[derive(Debug)]
|
||||
pub struct Error(pub String);
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
impl Error {
|
||||
pub fn grammar(message: &str) -> Self {
|
||||
Error(format!("Grammar error: {}", message))
|
||||
}
|
||||
|
||||
pub fn regex(message: &str) -> Self {
|
||||
Error(format!("Regex error: {}", message))
|
||||
}
|
||||
|
||||
pub fn undefined_symbol(name: &str) -> Self {
|
||||
Error(format!("Undefined symbol `{}`", name))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
fn from(error: serde_json::Error) -> Self {
|
||||
Error(error.to_string())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue