Show artifacts on failure

This commit is contained in:
greg 2018-04-24 23:11:04 -07:00
parent 8e42f7e0bc
commit a1016293ac

View File

@ -92,22 +92,20 @@ impl UnfinishedComputation {
impl FinishedComputation { impl FinishedComputation {
pub fn to_repl(&self) -> String { pub fn to_repl(&self) -> String {
match self.text_output { let mut buf = String::new();
Ok(ref output) => { for stage in ["tokens", "parse_trace", "ast", "symbol_table", "type_check"].iter() {
let mut buf = String::new(); if let Some(artifact) = self.artifacts.get(&stage.to_string()) {
for stage in ["tokens", "parse_trace", "ast", "symbol_table", "type_check"].iter() { let color = artifact.text_color;
if let Some(artifact) = self.artifacts.get(&stage.to_string()) { let stage = stage.color(color).bold();
let color = artifact.text_color; let output = artifact.debug_output.color(color);
let stage = stage.color(color).bold(); write!(&mut buf, "{}: {}\n", stage, output).unwrap();
let output = artifact.debug_output.color(color);
write!(&mut buf, "{}: {}\n", stage, output).unwrap();
}
}
write!(&mut buf, "{}", output).unwrap();
buf
} }
Err(ref s) => format!("{} {}", "Error: ".red().bold(), s)
} }
match self.text_output {
Ok(ref output) => write!(&mut buf, "{}", output).unwrap(),
Err(ref err) => write!(&mut buf, "{} {}", "Error: ".red().bold(), err).unwrap(),
}
buf
} }
pub fn to_noninteractive(&self) -> Option<String> { pub fn to_noninteractive(&self) -> Option<String> {
match self.text_output { match self.text_output {