Skip to content

Commit

Permalink
Propagate error instead of panic for take_bytes (#5395)
Browse files Browse the repository at this point in the history
* Propagate Error instead of panic

* Improve error message
  • Loading branch information
viirya authored Feb 13, 2024
1 parent c9029c5 commit 1b06d78
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arrow-select/src/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,11 @@ fn take_bytes<T: ByteArrayType, IndexType: ArrowPrimitiveType>(
nulls = Some(null_buf.into())
}

T::Offset::from_usize(values.len()).expect("offset overflow");
T::Offset::from_usize(values.len()).ok_or(ArrowError::ComputeError(format!(
"Offset overflow for {}BinaryArray: {}",
T::Offset::PREFIX,
values.len()
)))?;

let array_data = ArrayData::builder(T::DATA_TYPE)
.len(data_len)
Expand Down

0 comments on commit 1b06d78

Please sign in to comment.