mirror of
https://github.com/artegoser/ONLang
synced 2024-11-05 20:43:57 +03:00
fix: replace info.message() to info.payload()
This commit is contained in:
parent
b5970aaac6
commit
5a79cede01
2 changed files with 16 additions and 7 deletions
|
@ -219,8 +219,10 @@ impl Interpreter {
|
|||
fn input(&self, value: &String) -> Value {
|
||||
let mut input = String::new();
|
||||
print!("{}", value);
|
||||
io::stdout().flush().unwrap_or_default();
|
||||
io::stdin().read_line(&mut input).unwrap_or_default();
|
||||
io::stdout().flush().expect("Couldn't flush Stdout");
|
||||
io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("Couldn't read from Stdin");
|
||||
Value::String(input.trim_end().to_string())
|
||||
}
|
||||
|
||||
|
@ -625,24 +627,22 @@ impl Interpreter {
|
|||
std::process::exit(1);
|
||||
}
|
||||
fn unk_token(&self, name: &str) {
|
||||
println!(
|
||||
panic!(
|
||||
"\n{} {} | {} {}",
|
||||
"Unexpected token name:".red(),
|
||||
name.bold().black(),
|
||||
"pos:".green(),
|
||||
self.pos
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
fn error(&self, name: &str) {
|
||||
println!(
|
||||
panic!(
|
||||
"\n{} {} | {} {}",
|
||||
"Error:".red(),
|
||||
name.bold().black(),
|
||||
"pos:".green(),
|
||||
self.pos
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -15,8 +15,17 @@ mod interpreter;
|
|||
use interpreter::Interpreter;
|
||||
|
||||
fn main() {
|
||||
let start = Instant::now();
|
||||
std::panic::set_hook(Box::new(|info| {
|
||||
eprint!(
|
||||
"{msg}",
|
||||
msg = match info.payload().downcast_ref::<String>() {
|
||||
None => "Program panicked without a message!".to_owned(),
|
||||
Some(x) => x.to_string(),
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
let start = Instant::now();
|
||||
let args = Args::parse();
|
||||
if args.verbose == true {
|
||||
println!("Running: {}\n", args.file);
|
||||
|
|
Loading…
Reference in a new issue