Skip to content

Commit 58a9cd5

Browse files
robert3005claude
andcommitted
Require a kind on every vortex_err!, vortex_ensure! and vortex_panic!
A message with no leading `Kind:` still compiled and quietly became Other. The previous commits tagged every vortex_err!/vortex_bail! site, but the untagged form survived in 1133 other places: vortex_ensure! and vortex_ensure_eq! pass their message straight to an untagged vortex_bail!, so 748 checks returned Other errors callers could see; 350 vortex_panic! calls printed "Other error:"; and wrapper macros in vortex-jni and vortex-duckdb forwarded bare messages the same way. Every one now names its kind, chosen by reading the site: InvalidArgument 449 ValueError MismatchedTypes 272 TypeError AssertionFailed 182 AssertionError OutOfBounds 99 IndexError Serde 54 ValueError, as json.JSONDecodeError Overflow 32 OverflowError NotImplemented 31 NotImplementedError Io 7 OSError Other 5 RuntimeError NotFound 2 KeyError The split that mattered most for vortex_ensure!: a check on what the caller passed in (a constructor's lengths, a builder's dtype) is InvalidArgument or MismatchedTypes, a length mismatch is never a type error, and a check that a kernel, rewrite or executor kept its own contract (a reduced array changing dtype, a take producing the wrong length) is AssertionFailed. Checks made while decoding metadata or a wire format are Serde. The untagged arms are gone from vortex_err! and vortex_panic!. In their place an arm raises a compile error naming the fix, e.g. vortex_err! needs a kind before its message, e.g. `vortex_err!(InvalidArgument: "negative length {}")` vortex_ensure! reaches the same error through vortex_bail!. In vortex_panic! the arm sits before the `$err:expr` arms, which a bare message would otherwise match. The now-unused panic_fmt helper is removed. compile_fail doctests on the three macros keep the untagged form from coming back. vortex_ensure! without a message still produces AssertionFailed naming its condition, as before. duckdb_try! takes its message as `$msg:literal` rather than `$msg:expr`: a fragment captured as expr cannot match vortex_err!'s literal matcher once forwarded. Its message arms use Other, like its existing message-less arm, since DuckDB's C API reports only a bare failure status. Signed-off-by: Robert Kruszewski <github@robertk.io> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S7EtMqoZ91rrCCh9vS2yTm
1 parent 29bc298 commit 58a9cd5

352 files changed

Lines changed: 1418 additions & 1333 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎encodings/alp/src/alp/array.rs‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl VTable for ALP {
9696
}
9797

9898
fn buffer(_array: ArrayView<'_, Self>, idx: usize) -> BufferHandle {
99-
vortex_panic!("ALPArray buffer index {idx} out of bounds")
99+
vortex_panic!(OutOfBounds: "ALPArray buffer index {idx} out of bounds")
100100
}
101101

102102
fn buffer_name(_array: ArrayView<'_, Self>, _idx: usize) -> Option<String> {
@@ -260,7 +260,7 @@ impl ALPData {
260260
encoded.dtype(),
261261
DType::Primitive(PType::I32 | PType::I64, _)
262262
),
263-
"ALP encoded ints have invalid DType {}",
263+
MismatchedTypes: "ALP encoded ints have invalid DType {}",
264264
encoded.dtype(),
265265
);
266266

@@ -269,15 +269,15 @@ impl ALPData {
269269
let Exponents { e, f } = exponents;
270270
match encoded.dtype().as_ptype() {
271271
PType::I32 => {
272-
vortex_ensure!(exponents.e <= f32::MAX_EXPONENT, "e out of bounds: {e}");
273-
vortex_ensure!(exponents.f <= f32::MAX_EXPONENT, "f out of bounds: {f}");
272+
vortex_ensure!(exponents.e <= f32::MAX_EXPONENT, InvalidArgument: "e out of bounds: {e}");
273+
vortex_ensure!(exponents.f <= f32::MAX_EXPONENT, InvalidArgument: "f out of bounds: {f}");
274274
if let Some(patches) = patches {
275275
Self::validate_patches::<f32>(patches, encoded)?;
276276
}
277277
}
278278
PType::I64 => {
279-
vortex_ensure!(e <= f64::MAX_EXPONENT, "e out of bounds: {e}");
280-
vortex_ensure!(f <= f64::MAX_EXPONENT, "f out of bounds: {f}");
279+
vortex_ensure!(e <= f64::MAX_EXPONENT, InvalidArgument: "e out of bounds: {e}");
280+
vortex_ensure!(f <= f64::MAX_EXPONENT, InvalidArgument: "f out of bounds: {f}");
281281

282282
if let Some(patches) = patches {
283283
Self::validate_patches::<f64>(patches, encoded)?;
@@ -290,7 +290,7 @@ impl ALPData {
290290
if let Some(patches) = patches {
291291
vortex_ensure!(
292292
patches.array_len() == encoded.len(),
293-
"patches array_len != encoded len: {} != {}",
293+
InvalidArgument: "patches array_len != encoded len: {} != {}",
294294
patches.array_len(),
295295
encoded.len()
296296
);
@@ -322,15 +322,15 @@ impl ALPData {
322322
) -> VortexResult<()> {
323323
vortex_ensure!(
324324
patches.array_len() == encoded.len(),
325-
"patches array_len != encoded len: {} != {}",
325+
InvalidArgument: "patches array_len != encoded len: {} != {}",
326326
patches.array_len(),
327327
encoded.len()
328328
);
329329

330330
let expected_type = DType::Primitive(T::PTYPE, encoded.dtype().nullability());
331331
vortex_ensure!(
332332
patches.dtype() == &expected_type,
333-
"Expected patches type {expected_type}, actual {}",
333+
MismatchedTypes: "Expected patches type {expected_type}, actual {}",
334334
patches.dtype(),
335335
);
336336

@@ -447,12 +447,12 @@ fn validate_parts(
447447
ALPData::validate_components(encoded, exponents, patches.as_ref())?;
448448
vortex_ensure!(
449449
encoded.len() == len,
450-
"ALP encoded len {} != outer len {len}",
450+
InvalidArgument: "ALP encoded len {} != outer len {len}",
451451
encoded.len(),
452452
);
453453
vortex_ensure!(
454454
&logical_dtype == dtype,
455-
"ALP dtype {} does not match encoded logical dtype {}",
455+
MismatchedTypes: "ALP dtype {} does not match encoded logical dtype {}",
456456
dtype,
457457
logical_dtype,
458458
);

‎encodings/alp/src/alp/compress.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ macro_rules! match_each_alp_float_ptype {
3939
type $enc = f64;
4040
$body
4141
}
42-
_ => vortex_panic!("ALP can only encode f32 and f64, got {}", ptype),
42+
_ => vortex_panic!(MismatchedTypes: "ALP can only encode f32 and f64, got {}", ptype),
4343
}
4444
}};
4545
}

‎encodings/alp/src/alp/plugin.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl ArrayPlugin for ALPPatchedPlugin {
5454
) -> VortexResult<ArrayRef> {
5555
vortex_ensure!(
5656
parts.serialized_id == self.id(),
57-
"ALP plugin does not recognize serialized ID {}",
57+
Serde: "ALP plugin does not recognize serialized ID {}",
5858
parts.serialized_id,
5959
);
6060
let alp_array = Array::<ALP>::try_from_parts(ArrayVTable::deserialize(

‎encodings/alp/src/alp_rd/array.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl VTable for ALPRD {
121121
}
122122

123123
fn buffer(_array: ArrayView<'_, Self>, idx: usize) -> BufferHandle {
124-
vortex_panic!("ALPRDArray buffer index {idx} out of bounds")
124+
vortex_panic!(OutOfBounds: "ALPRDArray buffer index {idx} out of bounds")
125125
}
126126

127127
fn buffer_name(_array: ArrayView<'_, Self>, _idx: usize) -> Option<String> {
@@ -478,12 +478,12 @@ fn validate_parts(
478478

479479
vortex_ensure!(
480480
left_parts.len() == len,
481-
"left_parts len {} != outer len {len}",
481+
InvalidArgument: "left_parts len {} != outer len {len}",
482482
left_parts.len(),
483483
);
484484
vortex_ensure!(
485485
right_parts.len() == len,
486-
"right_parts len {} != outer len {len}",
486+
InvalidArgument: "right_parts len {} != outer len {len}",
487487
right_parts.len(),
488488
);
489489

@@ -505,15 +505,15 @@ fn validate_parts(
505505
};
506506
vortex_ensure!(
507507
right_parts.dtype() == &expected_right_parts_dtype,
508-
"right_parts dtype {} does not match expected {}",
508+
MismatchedTypes: "right_parts dtype {} does not match expected {}",
509509
right_parts.dtype(),
510510
expected_right_parts_dtype,
511511
);
512512

513513
if let Some(patches) = left_parts_patches {
514514
vortex_ensure!(
515515
patches.array_len() == len,
516-
"patches array_len {} != outer len {len}",
516+
InvalidArgument: "patches array_len {} != outer len {len}",
517517
patches.array_len(),
518518
);
519519
// Left-parts exceptions are always all-valid and are stored as the non-nullable left-parts
@@ -523,7 +523,7 @@ fn validate_parts(
523523
let expected = left_parts.dtype().as_nonnullable();
524524
vortex_ensure!(
525525
patches.dtype() == &expected,
526-
"patches dtype {} must be the non-nullable left_parts dtype {}",
526+
MismatchedTypes: "patches dtype {} must be the non-nullable left_parts dtype {}",
527527
patches.dtype(),
528528
expected,
529529
);

‎encodings/alp/src/alp_rd/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ where
146146
T::UINT: NativePType,
147147
{
148148
if left_parts.len() != right_parts.len() {
149-
vortex_panic!("alp_rd_decode: left_parts.len != right_parts.len");
149+
vortex_panic!(AssertionFailed: "alp_rd_decode: left_parts.len != right_parts.len");
150150
}
151151

152152
if let Some(patches) = left_parts_patches {

‎encodings/bytebool/src/array.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ impl VTable for ByteBool {
8585
fn buffer(array: ArrayView<'_, Self>, idx: usize) -> BufferHandle {
8686
match idx {
8787
0 => array.buffer().clone(),
88-
_ => vortex_panic!("ByteBoolArray buffer index {idx} out of bounds"),
88+
_ => vortex_panic!(OutOfBounds: "ByteBoolArray buffer index {idx} out of bounds"),
8989
}
9090
}
9191

9292
fn buffer_name(_array: ArrayView<'_, Self>, idx: usize) -> Option<String> {
9393
match idx {
9494
0 => Some("values".to_string()),
95-
_ => vortex_panic!("ByteBoolArray buffer_name index {idx} out of bounds"),
95+
_ => vortex_panic!(OutOfBounds: "ByteBoolArray buffer_name index {idx} out of bounds"),
9696
}
9797
}
9898

@@ -103,7 +103,7 @@ impl VTable for ByteBool {
103103
) -> VortexResult<ArrayParts<Self>> {
104104
vortex_ensure!(
105105
buffers.len() == 1,
106-
"Expected 1 buffer, got {}",
106+
InvalidArgument: "Expected 1 buffer, got {}",
107107
buffers.len()
108108
);
109109
let data = ByteBoolData::new(buffers[0].clone());
@@ -262,15 +262,15 @@ impl ByteBoolData {
262262
let expected_dtype = DType::Bool(validity.nullability());
263263
vortex_ensure!(
264264
dtype == &expected_dtype,
265-
"expected dtype {expected_dtype}, got {dtype}"
265+
MismatchedTypes: "expected dtype {expected_dtype}, got {dtype}"
266266
);
267267
vortex_ensure!(
268268
buffer.len() == len,
269-
"expected len {len}, got {}",
269+
InvalidArgument: "expected len {len}, got {}",
270270
buffer.len()
271271
);
272272
if let Some(vlen) = validity.maybe_len() {
273-
vortex_ensure!(vlen == len, "expected validity len {len}, got {vlen}");
273+
vortex_ensure!(vlen == len, InvalidArgument: "expected validity len {len}, got {vlen}");
274274
}
275275
Ok(())
276276
}

‎encodings/datetime-parts/src/array.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ impl VTable for DateTimeParts {
115115
}
116116

117117
fn buffer(_array: ArrayView<'_, Self>, idx: usize) -> BufferHandle {
118-
vortex_panic!("DateTimePartsArray buffer index {idx} out of bounds")
118+
vortex_panic!(OutOfBounds: "DateTimePartsArray buffer index {idx} out of bounds")
119119
}
120120

121121
fn buffer_name(_array: ArrayView<'_, Self>, idx: usize) -> Option<String> {
122-
vortex_panic!("DateTimePartsArray buffer_name index {idx} out of bounds")
122+
vortex_panic!(OutOfBounds: "DateTimePartsArray buffer_name index {idx} out of bounds")
123123
}
124124

125125
fn with_buffers(
@@ -309,7 +309,7 @@ impl DateTimePartsData {
309309
subseconds: &ArrayRef,
310310
len: usize,
311311
) -> VortexResult<()> {
312-
vortex_ensure!(days.len() == len, "expected len {len}, got {}", days.len());
312+
vortex_ensure!(days.len() == len, InvalidArgument: "expected len {len}, got {}", days.len());
313313

314314
if !days.dtype().is_int() || (dtype.is_nullable() != days.dtype().is_nullable()) {
315315
vortex_bail!(

‎encodings/datetime-parts/src/compute/take.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ fn take_datetime_parts(
4949
// If they became nullable due to nullable indices, we need to fill nulls.
5050
// But first, we need to check that the types are consistent.
5151
if !taken_days.dtype().is_nullable() {
52-
vortex_panic!("Mismatched types: days is not nullable, seconds is nullable");
52+
vortex_panic!(MismatchedTypes: "Mismatched types: days is not nullable, seconds is nullable");
5353
}
5454
if !taken_seconds.dtype().is_nullable() {
55-
vortex_panic!("Mismatched types: seconds is not nullable, days is nullable");
55+
vortex_panic!(MismatchedTypes: "Mismatched types: seconds is not nullable, days is nullable");
5656
}
5757
if !taken_subseconds.dtype().is_nullable() {
58-
vortex_panic!("Mismatched types: subseconds is not nullable, days & seconds are nullable");
58+
vortex_panic!(MismatchedTypes: "Mismatched types: subseconds is not nullable, days & seconds are nullable");
5959
}
6060
if !indices.dtype().is_nullable() {
61-
vortex_panic!("Mismatched types: indices are not nullable, days & seconds are nullable");
61+
vortex_panic!(MismatchedTypes: "Mismatched types: indices are not nullable, days & seconds are nullable");
6262
}
6363

6464
let seconds_fill = array

‎encodings/datetime-parts/src/ops.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl OperationsVTable<DateTimeParts> for DateTimeParts {
2626
) -> VortexResult<Scalar> {
2727
let DType::Extension(ext) = array.dtype().clone() else {
2828
vortex_panic!(
29-
"DateTimePartsArray must have extension dtype, found {}",
29+
MismatchedTypes: "DateTimePartsArray must have extension dtype, found {}",
3030
array.dtype()
3131
);
3232
};

‎encodings/datetime-parts/src/timestamp.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn combine(ts_parts: TimestampParts, time_unit: TimeUnit) -> i64 {
7171
TimeUnit::Microseconds => 1_000_000,
7272
TimeUnit::Milliseconds => 1_000,
7373
TimeUnit::Seconds => 1,
74-
TimeUnit::Days => vortex_panic!("Cannot handle day-level data"),
74+
TimeUnit::Days => vortex_panic!(NotImplemented: "Cannot handle day-level data"),
7575
};
7676

7777
ts_parts.days as i64 * SECONDS_PER_DAY * divisor

0 commit comments

Comments
 (0)