Skip to content

Commit 00c0298

Browse files
committed
Improve error message
1 parent 6be2101 commit 00c0298

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/common/composed_extension_codec.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use datafusion::common::internal_datafusion_err;
12
use datafusion::error::DataFusionError;
23
use datafusion::error::Result;
34
use datafusion::execution::FunctionRegistry;
@@ -7,7 +8,6 @@ use datafusion_proto::physical_plan::PhysicalExtensionCodec;
78
use prost::Message;
89
use std::fmt::Debug;
910
use std::sync::Arc;
10-
1111
// Code taken from https://github.com/apache/datafusion/blob/10f41887fa40d7d425c19b07857f80115460a98e/datafusion/proto/src/physical_plan/mod.rs
1212
// TODO: It's not yet on DF 49, once upgrading to DF 50 we can remove this
1313

@@ -46,12 +46,13 @@ impl ComposedPhysicalExtensionCodec {
4646
let proto =
4747
DataEncoderTuple::decode(buf).map_err(|e| DataFusionError::Internal(e.to_string()))?;
4848

49-
let codec =
50-
self.codecs
51-
.get(proto.encoder_position as usize)
52-
.ok_or(DataFusionError::Internal(
53-
"Can't find required codec in codec list".to_owned(),
54-
))?;
49+
let pos = proto.encoder_position as usize;
50+
let codec = self.codecs.get(pos).ok_or_else(|| {
51+
internal_datafusion_err!(
52+
"Can't find required codec in position {pos} in codec list with {} elements",
53+
self.codecs.len()
54+
)
55+
})?;
5556

5657
decode(codec.as_ref(), &proto.blob)
5758
}

0 commit comments

Comments
 (0)