Overhaul CLI error handling to allow multiple levels of context

This commit is contained in:
Max Brunsfeld 2019-05-30 16:52:30 -07:00
parent b7bc2d30ae
commit d274e81d0d
17 changed files with 214 additions and 129 deletions

View file

@ -29,8 +29,9 @@ pub fn parse_file_at_path(
let mut _log_session = None;
let mut parser = Parser::new();
parser.set_language(language)?;
let mut source_code = fs::read(path)
.map_err(|e| Error(format!("Error reading source file {:?}: {}", path, e)))?;
let mut source_code = fs::read(path).map_err(Error::wrap(|| {
format!("Error reading source file {:?}", path)
}))?;
// If the `--cancel` flag was passed, then cancel the parse
// when the user types a newline.