mirror of
https://github.com/nushell/nushell
synced 2024-12-26 21:13:19 +00:00
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.
This commit is contained in:
parent
57d425d929
commit
946f7256e4
1 changed files with 4 additions and 4 deletions
|
@ -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 formatted data",
|
||||||
"unexpected data during save",
|
"consider piping to a converter (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),
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue