Friendly error message for access beyond end (#6944)

Adds `ShellError::AccessEmptyContent`
This commit is contained in:
WindSoilder
2022-10-30 01:47:50 +08:00
committed by GitHub
parent 7039602e4d
commit 4f7f6a2932
7 changed files with 46 additions and 11 deletions

View File

@ -316,7 +316,7 @@ impl NuDataFrame {
let column = conversion::create_column(&series, row, row + 1, span)?;
if column.len() == 0 {
Err(ShellError::AccessBeyondEnd(series.len(), span))
Err(ShellError::AccessEmptyContent(span))
} else {
let value = column
.into_iter()

View File

@ -138,6 +138,8 @@ fn update(
for idx in 0..*val {
if let Some(v) = input.next() {
pre_elems.push(v);
} else if idx == 0 {
return Err(ShellError::AccessEmptyContent(*span));
} else {
return Err(ShellError::AccessBeyondEnd(idx - 1, *span));
}