mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 19:59:16 +02:00
Refactor error make
(#10923)
- Replaced `start`/`end` with span. - Fixed standard library. - Add `help` option. - Add a couple more errors for invalid record types. Resolve #10914 # Description # User-Facing Changes - **BREAKING CHANGE:** `error make` now takes in `span` instead of `start`/`end`: ```Nushell error make { msg: "Message" label: { text: "Label text" span: (metadata $var).span } } ``` - `error make` now has a `help` argument for custom error help.
This commit is contained in:
@@ -31,7 +31,7 @@ export def --env add [
|
||||
let exp = ($p | path expand)
|
||||
if ($exp | path type) != 'dir' {
|
||||
let span = (metadata $p).span
|
||||
error make {msg: "not a directory", label: {text: "not a directory", start: $span.start, end: $span.end } }
|
||||
error make {msg: "not a directory", label: {text: "not a directory", span: $span } }
|
||||
}
|
||||
$abspaths = ($abspaths | append $exp)
|
||||
}
|
||||
@@ -106,8 +106,7 @@ export def --env goto [shell?: int] {
|
||||
msg: $"(ansi red_bold)invalid_shell_index(ansi reset)"
|
||||
label: {
|
||||
text: $"`shell` should be between 0 and (($env.DIRS_LIST | length) - 1)"
|
||||
start: $span.start
|
||||
end: $span.end
|
||||
span: $span
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user