nushell/crates/nu-command/src/filesystem
Erich Gubler 83b1ec83c9
feat(rm)!: use arg. spans for I/O errors (#8964)
# Description

Currently, error spans for I/O errors in an `rm` invocation always point
to the `rm` argument. This isn't ideal, because the user loses context
as to which “target” actually had a problem:


![image](https://user-images.githubusercontent.com/658538/235723366-50db727e-9ba2-4d16-afc6-6a2406c584e0.png)

Shadow the existing `span` variable in outer scope in `rm`'s
implementation for the errors that may be detected while handling I/O
results. This is desired, because all failures from this point are
target-specific, and pointing at the argument that generated the target
instead is better. The end user should now see this:


![image](https://user-images.githubusercontent.com/658538/235724345-1d2e98e0-6b20-4bf5-b8a2-8b4368cdfb05.png)

# User-Facing Changes
* When `rm` encounters I/O errors, their spans now point to the “target”
argument associated with the error, rather than the `rm` token.

# Tests + Formatting


No tests currently cover this. I'm open to adding tests, but adding as
follow-up sounds better ATM, since this wasn't covered before.

# After Submitting

Nothing needs to be done here, AFAIK. No I/O errors are currently
demonstrated in official docs, though maybe they should be?
2023-05-03 23:12:16 +02:00
..
cd_query.rs Fix typos by codespell (#7600) 2022-12-26 02:31:26 -05:00
cd.rs #8027 Hide implementation details in invalid cd call (#8049) 2023-02-13 02:24:48 +00:00
cp.rs Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
glob.rs Feat: listen for signal on glob command (#9088) 2023-05-03 21:51:25 +02:00
ls.rs Update some help examples (#8759) 2023-04-05 18:36:00 -05:00
mkdir.rs Document and critically review ShellError variants - Ep. 2 (#8326) 2023-03-06 11:31:07 +01:00
mod.rs move BufferedReader out of nu-command (#7697) 2023-01-06 15:22:17 -08:00
mv.rs Better error message for mv when file not found (#8586) 2023-03-23 11:31:49 -07:00
open.rs Add rest and glob support to 'open' (#8506) 2023-03-18 08:51:39 +13:00
rm.rs feat(rm)!: use arg. spans for I/O errors (#8964) 2023-05-03 23:12:16 +02:00
save.rs Box ShellError in Value::Error (#8375) 2023-03-12 09:57:27 +01:00
start.rs docs: Add missing space in Filesystem/start's usage (#8458) 2023-03-15 07:16:41 -05:00
touch.rs Document and critically review ShellError variants - Ep. 2 (#8326) 2023-03-06 11:31:07 +01:00
util.rs move BufferedReader out of nu-command (#7697) 2023-01-06 15:22:17 -08:00
watch.rs Update some help examples (#8759) 2023-04-05 18:36:00 -05:00