changing to miette instead of color_eyre

This commit is contained in:
Chris Cochrun 2024-11-19 06:23:01 -06:00
parent 45717708ba
commit 04a470d771
4 changed files with 215 additions and 121 deletions

View file

@ -1,5 +1,5 @@
use color_eyre::{eyre::eyre, Result};
use env::Environment;
use miette::{miette, IntoDiagnostic, Result};
use printer::print;
use reader::read;
use rustyline::{config::Configurer, error::ReadlineError, Editor};
@ -26,7 +26,7 @@ pub fn main() -> Result<()> {
.iter()
.map(|a| match a {
Value::Number(a) => Ok(*a),
_ => Err(eyre!("Should be a number")),
_ => Err(miette!("Should be a number")),
})
.flatten()
.collect();
@ -44,7 +44,7 @@ pub fn main() -> Result<()> {
.iter()
.map(|a| match a {
Value::Number(a) => Ok(*a),
_ => Err(eyre!("Should be a number")),
_ => Err(miette!("Should be a number")),
})
.flatten()
.collect();
@ -60,7 +60,7 @@ pub fn main() -> Result<()> {
let entry = rl.readline(">> ");
match entry {
Ok(line) => {
rl.add_history_entry(line.as_str())?;
rl.add_history_entry(line.as_str()).into_diagnostic()?;
match read_eval_print(line.as_str(), &mut env) {
Ok(s) => println!("{s}"),
Err(e) => eprintln!("{e}"),

View file

@ -1,13 +1,7 @@
use std::collections::HashMap;
use color_eyre::{
eyre::{eyre, ContextCompat},
Result,
};
use env::Environment;
use miette::{miette, IntoDiagnostic, Result};
use printer::print;
use reader::read;
use regex::Regex;
use rustyline::{config::Configurer, error::ReadlineError, Editor};
pub mod env;
@ -32,7 +26,7 @@ fn main() -> Result<()> {
.iter()
.map(|a| match a {
Value::Number(a) => Ok(*a),
_ => Err(eyre!("Should be a number")),
_ => Err(miette!("Should be a number")),
})
.flatten()
.collect();
@ -50,7 +44,7 @@ fn main() -> Result<()> {
.iter()
.map(|a| match a {
Value::Number(a) => Ok(*a),
_ => Err(eyre!("Should be a number")),
_ => Err(miette!("Should be a number")),
})
.flatten()
.collect();
@ -66,7 +60,7 @@ fn main() -> Result<()> {
let entry = rl.readline(">> ");
match entry {
Ok(line) => {
rl.add_history_entry(line.as_str())?;
rl.add_history_entry(line.as_str()).into_diagnostic()?;
match read_eval_print(line.as_str(), &env) {
Ok(s) => println!("{s}"),
Err(e) => eprintln!("{e}"),