From a1016293ac6d7abba8853e3dd2912d80500446ba Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 24 Apr 2018 23:11:04 -0700 Subject: [PATCH] Show artifacts on failure --- schala-repl/src/language.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 4008afc..c4d65e4 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -92,22 +92,20 @@ impl UnfinishedComputation { impl FinishedComputation { pub fn to_repl(&self) -> String { - match self.text_output { - Ok(ref output) => { - let mut buf = String::new(); - for stage in ["tokens", "parse_trace", "ast", "symbol_table", "type_check"].iter() { - if let Some(artifact) = self.artifacts.get(&stage.to_string()) { - let color = artifact.text_color; - let stage = stage.color(color).bold(); - let output = artifact.debug_output.color(color); - write!(&mut buf, "{}: {}\n", stage, output).unwrap(); - } - } - write!(&mut buf, "{}", output).unwrap(); - buf + let mut buf = String::new(); + for stage in ["tokens", "parse_trace", "ast", "symbol_table", "type_check"].iter() { + if let Some(artifact) = self.artifacts.get(&stage.to_string()) { + let color = artifact.text_color; + let stage = stage.color(color).bold(); + let output = artifact.debug_output.color(color); + write!(&mut buf, "{}: {}\n", stage, output).unwrap(); } - 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 { match self.text_output {