Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Include column name in exception when ColumnSource.cast fails #6078

Merged
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ default <T> ColumnSource<T> getColumnSource(String sourceName, Class<? extends T
@Nullable Class<?> componentType) {
@SuppressWarnings("rawtypes")
ColumnSource rawColumnSource = getColumnSource(sourceName);
// noinspection unchecked
return rawColumnSource.cast(clazz, componentType);
try {
// noinspection unchecked
return rawColumnSource.cast(clazz, componentType);
} catch (ClassCastException ex) {
throw new RuntimeException(
"Error retrieving ColumnSource with type " + clazz.getName() + " for column " + sourceName, ex);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s not better, or precise enough.

  1. No throwing RTEs. Throw something more specific.
  2. You should make it clearer that you’re throwing an exception because of a type mismatch. You would have failed before for a missing column.
  3. I think the existing error messaging is clearer and more specific.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better change would just be to add an optional "name" prefix to ColumnSource.cast, so the existing exceptions could refer to "ColumnSource ".

}

// -----------------------------------------------------------------------------------------------------------------
Expand Down
Loading