From 946f7256e424b196e063d7963116fb359ff6fd04 Mon Sep 17 00:00:00 2001 From: Belhorma Bendebiche Date: Sat, 16 Nov 2019 19:04:33 -0500 Subject: [PATCH 1/2] Improve error messages for save `save` attempts to convert input based on the target filename extension, and expects a stream of text otherwise. However the error message is unclear and provides little guidance, hopefully this is less confusing to new users. It might be worthwhile to also add a hint about adding an extension, though I'm not sure if it's possible to emit multiple diagnostics. --- src/commands/save.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/save.rs b/src/commands/save.rs index 48cfa1acc9..e91e6ce763 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -19,8 +19,8 @@ macro_rules! process_string { } _ => { break $scope Err(ShellError::labeled_error( - "Save could not successfully save", - "unexpected data during save", + "Save requires formatted data", + "consider piping to a converter (see `help commands`)", $name_tag, )); } @@ -214,9 +214,9 @@ fn save( match content { Ok(save_data) => match std::fs::write(full_path, save_data) { Ok(o) => o, - Err(e) => yield Err(ShellError::labeled_error(e.to_string(), "for command", name)), + Err(e) => yield Err(ShellError::labeled_error(e.to_string(), "IO error while saving", name)), }, - Err(e) => yield Err(ShellError::labeled_error(e.to_string(), "for command", name)), + Err(e) => yield Err(e), } }; From f992f5de95ebc61a5d3adde0440d7f3510d27df3 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 17 Nov 2019 14:13:52 +1300 Subject: [PATCH 2/2] Update save.rs --- src/commands/save.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/save.rs b/src/commands/save.rs index e91e6ce763..4aaac0b14f 100644 --- a/src/commands/save.rs +++ b/src/commands/save.rs @@ -19,8 +19,8 @@ macro_rules! process_string { } _ => { break $scope Err(ShellError::labeled_error( - "Save requires formatted data", - "consider piping to a converter (see `help commands`)", + "Save requires string data", + "consider converting data to string (see `help commands`)", $name_tag, )); }