Merge pull request #976 from bndbsh/save-error

Improve error messages for save
This commit is contained in:
Jonathan Turner 2019-11-17 14:58:55 +13:00 committed by GitHub
commit 9dfc647386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,8 +19,8 @@ macro_rules! process_string {
} }
_ => { _ => {
break $scope Err(ShellError::labeled_error( break $scope Err(ShellError::labeled_error(
"Save could not successfully save", "Save requires string data",
"unexpected data during save", "consider converting data to string (see `help commands`)",
$name_tag, $name_tag,
)); ));
} }
@ -214,9 +214,9 @@ fn save(
match content { match content {
Ok(save_data) => match std::fs::write(full_path, save_data) { Ok(save_data) => match std::fs::write(full_path, save_data) {
Ok(o) => o, 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),
} }
}; };