Change ShellError for headers, Add sample_headers file to utils.rs

This commit is contained in:
Sam Hedin 2020-03-28 20:15:37 +01:00
parent 088561f6fe
commit 4cb3a6ecd7
2 changed files with 6 additions and 2 deletions

View file

@ -52,7 +52,7 @@ pub fn headers(
}
}).collect())
}
_ => Err(ShellError::untagged_runtime_error("Couldn't find all headers, was the input a properly formatted, non-empty table?")),
_ => Err(ShellError::unexpected_eof("Could not get headers, is the table empty?", rows[0].tag.span))
}?;
//Each row is a dictionary with the headers as keys
@ -67,7 +67,7 @@ pub fn headers(
}
yield Ok(ReturnSuccess::Value(UntaggedValue::Row(Dictionary{entries}).into_value(r.tag.clone())))
}
_ => yield Err(ShellError::untagged_runtime_error("Couldn't iterate through rows, was the input a properly formatted table?"))
_ => yield Err(ShellError::unexpected_eof("Couldn't iterate through rows, was the input a properly formatted table?", r.tag.span))
}
}
};

View file

@ -317,6 +317,10 @@ mod tests {
loc: fixtures().join("sample_data.xlsx"),
at: 0
},
Res {
loc: fixtures().join("sample_headers.xlsx"),
at: 0
},
Res {
loc: fixtures().join("script.nu"),
at: 0