From b37e75948583fd726c9a9e9361095eddb44fba64 Mon Sep 17 00:00:00 2001 From: Raymon Zutekouw <40148684+Raymonzut@users.noreply.github.com> Date: Fri, 7 Jan 2022 14:48:47 +0100 Subject: [PATCH] Cleanup errors --- src/main.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index adb2ff7..9d7b7d6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::fs::File; use std::io::Write; -use anyhow::{Context, Result}; +use anyhow::Result; use string_builder::Builder; use structopt::StructOpt; @@ -73,7 +73,7 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) { String::from(variable_name), MemCell::allocate(state.alloc_cnt), ) { - panic!("Variable {} already exists", variable_name); + panic!("Variable '{}' already exists", variable_name); } state.alloc_cnt += 1; } @@ -192,9 +192,7 @@ fn instruct(statement: Pair, state: &mut State, out: &mut Builder) { Rule::include => { let file_path_raw = extract_operand(statement); let file_path = &file_path_raw[1..file_path_raw.len() - 1]; - let content = std::fs::read_to_string(&file_path) - .with_context(|| format!("could not read source file {:?}", file_path)) - .unwrap(); + let content = std::fs::read_to_string(&file_path).unwrap(); let parsed_file = MblfParser::parse(Rule::file, &content) .expect("Parse Error") .next() @@ -215,8 +213,7 @@ fn instruct(statement: Pair, state: &mut State, out: &mut Builder) { fn main() -> Result<(), Box> { let args = Cli::from_args(); - let content = std::fs::read_to_string(&args.input_file) - .with_context(|| format!("could not read source file {:?}", args.input_file))?; + let content = std::fs::read_to_string(&args.input_file)?; let mut builder = Builder::default();