Hacky fix for displaying error output non-interactively

This commit is contained in:
greg 2018-03-11 12:56:51 -07:00
parent 6140de9f9c
commit f56d7120c4
4 changed files with 6 additions and 4 deletions

View File

@ -19,7 +19,7 @@ pub struct EvalOptions {
pub struct LanguageOutput {
output: String,
artifacts: Vec<TraceArtifact>,
failed: bool,
pub failed: bool,
}
impl LanguageOutput {

View File

@ -111,8 +111,9 @@ fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInte
}
} else {
let output = language.evaluate_in_repl(&buffer, &options);
// if output.has_error....
if output.failed {
println!("{}", output.to_string());
}
}
}

View File

@ -6,5 +6,4 @@ fn main() {
print(main())
const xxx

View File

@ -49,6 +49,7 @@ impl ProgrammingLanguageInterface for Schala {
let token_errors: Vec<&String> = tokens.iter().filter_map(|t| t.get_error()).collect();
if token_errors.len() != 0 {
output.add_output(format!("Tokenization error: {:?}\n", token_errors));
output.failed = true;
return output;
}
}
@ -64,6 +65,7 @@ impl ProgrammingLanguageInterface for Schala {
(Err(err), trace) => {
output.add_artifact(TraceArtifact::new_parse_trace(trace));
output.add_output(format!("Parse error: {:?}\n", err.msg));
output.failed = true;
return output;
}
};