Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Improved error message #1179

Merged
merged 1 commit into from
Jul 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/array/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ pub fn try_check_offsets<O: Offset>(offsets: &[O], values_len: usize) -> Result<

pub fn check_indexes<K>(keys: &[K], len: usize) -> Result<()>
where
K: Copy + TryInto<usize>,
K: std::fmt::Debug + Copy + TryInto<usize>,
{
keys.iter().try_for_each(|key| {
let key: usize = (*key)
.try_into()
.map_err(|_| Error::oos("The dictionary key must fit in a `usize`"))?;
.map_err(|_| Error::oos(format!("The dictionary key must fit in a `usize`, but {:?} does not", key)))?;
if key >= len {
Err(Error::oos("The dictionary key must be smaller"))
Err(Error::oos(format!("One of the dictionary keys is {} but it must be < than the length of the dictionary values, which is {}", key, len)))
} else {
Ok(())
}
Expand Down