feat: expose duckdb_result_error_type() to populate ErrorCode in DuckDBFailure#752
Open
EdanStasiuk wants to merge 4 commits intoduckdb:mainfrom
Open
feat: expose duckdb_result_error_type() to populate ErrorCode in DuckDBFailure#752EdanStasiuk wants to merge 4 commits intoduckdb:mainfrom
EdanStasiuk wants to merge 4 commits intoduckdb:mainfrom
Conversation
Author
|
As this PR currently stands, all relevant unit tests are passing except for The way I see it, there's 3 way to address this:
Happy to go in whichever direction the maintainers prefer. |
Author
|
Un-drafting the PR with option 2, as described previously. Happy to make any changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #679. Currently every
DuckDBFailureerror carriesErrorCode::Unknownregardless of what actually went wrong. This is because duckdb-rs only reads a generic success/failure integer from the C API and never callsduckdb_result_error_type(), which has been available since DuckDB v0.10 and returns the actual error type.This PR adds
ErrorCode::Httpand a full mapping from allduckdb_error_typeC constants to RustErrorCodevariants, then callsduckdb_result_error_type()when constructingDuckDBFailureerrors from aduckdb_result. This allows users to match on specific error codes instead of parsing error message strings, which is fragile and breaks between DuckDB versions.After this change, errors from
execute_streamingandexecute_extracted_statementwill carry the correct code. For example,ErrorCode::Httpfor HTTP fetch failures,ErrorCode::ConstraintViolationfor constrain violations, andErrorCode::NotFoundfor missing tables.Tests
All test cases pass except for
types::test::test_dynamic_type, which is already failing on the main branch.