mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
Wrap open
parse errors from from
commands (#6877)
* Wrap `open` parse errors from `from` commands Minimal fix for #6843 This propagates the underlying errors from the called `from` commands and adds a top-level error with the full path and the understood file extension and resulting called command. * Repoint inner span for `from ...` to `open` * Add actionable message: refer to help or use --raw
This commit is contained in:
parent
ebca840d91
commit
79fd7d54b2
1 changed files with 10 additions and 1 deletions
|
@ -172,8 +172,17 @@ impl Command for Open {
|
|||
let block = engine_state.get_block(block_id);
|
||||
eval_block(engine_state, stack, block, output, false, false)
|
||||
} else {
|
||||
decl.run(engine_state, stack, &Call::new(arg_span), output)
|
||||
decl.run(engine_state, stack, &Call::new(call_span), output)
|
||||
}
|
||||
.map_err(|inner| {
|
||||
ShellError::GenericError(
|
||||
format!("Error while parsing as {}", ext),
|
||||
format!("Could not parse '{}' with `from {}`", path.display(), ext),
|
||||
Some(arg_span),
|
||||
Some(format!("Check out `help from {}` or `help from` for more options or open raw data with `open --raw '{}'`", ext, path.display())),
|
||||
vec![inner],
|
||||
)
|
||||
})
|
||||
}
|
||||
None => Ok(output),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue