From 14c9bd44efbb11daea7edec7b0b41b373b9f0eeb Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Mon, 2 May 2022 08:40:46 +1200 Subject: [PATCH] Adds error printing back in a couple places (#5400) --- crates/nu-protocol/src/pipeline_data.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/nu-protocol/src/pipeline_data.rs b/crates/nu-protocol/src/pipeline_data.rs index 8cbcadfdca..015da74592 100644 --- a/crates/nu-protocol/src/pipeline_data.rs +++ b/crates/nu-protocol/src/pipeline_data.rs @@ -5,8 +5,8 @@ use std::{ use crate::{ ast::{Call, PathMember}, - engine::{EngineState, Stack}, - Config, ListStream, RawStream, ShellError, Span, Value, + engine::{EngineState, Stack, StateWorkingSet}, + format_error, Config, ListStream, RawStream, ShellError, Span, Value, }; /// The foundational abstraction for input and output to commands @@ -455,7 +455,15 @@ impl PipelineData { for item in table { let stdout = std::io::stdout(); - let mut out = item.into_string("\n", config); + + let mut out = if let Value::Error { error } = item { + let working_set = StateWorkingSet::new(engine_state); + + format_error(&working_set, &error) + } else { + item.into_string("\n", config) + }; + out.push('\n'); match stdout.lock().write_all(out.as_bytes()) { @@ -467,7 +475,13 @@ impl PipelineData { None => { for item in self { let stdout = std::io::stdout(); - let mut out = item.into_string("\n", config); + let mut out = if let Value::Error { error } = item { + let working_set = StateWorkingSet::new(engine_state); + + format_error(&working_set, &error) + } else { + item.into_string("\n", config) + }; out.push('\n'); match stdout.lock().write_all(out.as_bytes()) {