feat: surface underlying BigQueryException message in JDBC exceptions#12982
feat: surface underlying BigQueryException message in JDBC exceptions#12982rhgoogle wants to merge 1 commit intogoogleapis:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates BigQueryStatement.java to include the original BigQueryException message in the JDBC exceptions thrown by the getStatementType, getQueryStatistics, and runQuery methods. The review feedback suggests refactoring the duplicated exception-handling logic into a utility class to improve maintainability and recommends adding unit tests to verify the new error messages and handle edge cases like null or empty messages.
| "BigQueryException during getStatementType: " + ex.getMessage(), ex); | ||
| } | ||
| throw new BigQueryJdbcException("BigQueryException during getStatementType", ex); | ||
| throw new BigQueryJdbcException("BigQueryException during getStatementType: " + ex.getMessage(), ex); |
There was a problem hiding this comment.
The logic for wrapping BigQueryException and surfacing its message is duplicated across getStatementType, getQueryStatistics, and runQuery. This duplication makes the code harder to maintain and increases the risk of inconsistencies. To align with repository practices, consider moving this shared logic to a separate helper or utility class.
References
- If code is duplicated and needs to be shared, move it to a separate helper/utility class.
| throw new BigQueryJdbcSqlSyntaxErrorException("BigQueryException during runQuery: " + ex.getMessage(), ex); | ||
| } | ||
| throw new BigQueryJdbcException("BigQueryException during runQuery", ex); | ||
| throw new BigQueryJdbcException("BigQueryException during runQuery: " + ex.getMessage(), ex); |
There was a problem hiding this comment.
The changes modify the error messages returned by the JDBC driver, which is a user-facing change. These changes should be accompanied by unit tests to verify that the underlying BigQueryException message is correctly surfaced and that the logic handles edge cases (e.g., null or empty messages) gracefully. Relying on manual verification of the built JAR is insufficient for maintaining code quality.
This PR surfaces the underlying BigQueryException message in JDBC exceptions to help debug issues in tools like Looker. Tested by verifying that the project compiles and the new strings are present in the built jar.