feat(error): display filename with the error message
This commit is contained in:
parent
32cfdfa07f
commit
442c4b7beb
3 changed files with 14 additions and 10 deletions
|
|
@ -4,23 +4,23 @@ use crate::{
|
|||
};
|
||||
|
||||
pub trait OSDBError {
|
||||
fn display(&self);
|
||||
fn display(&self, file: &str);
|
||||
}
|
||||
|
||||
impl OSDBError for MetaCommandParseError {
|
||||
fn display(&self) {
|
||||
println!("{self}")
|
||||
fn display(&self, file: &str) {
|
||||
println!("{file}: {self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl OSDBError for StatementParseError {
|
||||
fn display(&self) {
|
||||
println!("{self}")
|
||||
fn display(&self, file: &str) {
|
||||
println!("{file}: {self}")
|
||||
}
|
||||
}
|
||||
|
||||
impl OSDBError for CommandParseError {
|
||||
fn display(&self) {
|
||||
println!("{self}")
|
||||
fn display(&self, file: &str) {
|
||||
println!("{file}: {self}")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
Err(err) => err.display(),
|
||||
Err(err) => err.display("<stdin>"),
|
||||
}
|
||||
}
|
||||
println!("Good-bye");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue