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

Commit

Permalink
Improved error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Jul 23, 2022
1 parent dc77578 commit 42fbfb4
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 42fbfb4

Please sign in to comment.