Skip to content

Structured errors 2: more error types#24

Merged
tpellissier-msft merged 4 commits intomainfrom
user/tpellissier/structured-errors-2
Oct 22, 2025
Merged

Structured errors 2: more error types#24
tpellissier-msft merged 4 commits intomainfrom
user/tpellissier/structured-errors-2

Conversation

@tpellissier-msft
Copy link
Copy Markdown
Contributor

Copilot summary:

This pull request introduces structured error handling to the Dataverse SDK by adding custom error classes and subcodes, replacing generic exceptions with more descriptive, domain-specific errors. It also enhances HTTP error reporting with more details and improves validation and metadata error handling. Comprehensive tests are added to ensure proper error propagation and coverage.

Error Handling Enhancements

  • Added new error subcodes in error_codes.py for validation, SQL parsing, and metadata operations, enabling more granular error reporting.
  • Introduced custom error classes—ValidationError, MetadataError, and SQLParseError—in errors.py, extending DataverseError for structured exception handling.
  • Updated DataverseError and HttpError constructors to standardize error attributes, set default sources, and enrich HTTP error details (e.g., correlation IDs, retry-after, body excerpt). [1] [2]

SDK Codebase Changes

  • Replaced RuntimeError and ValueError with the new custom error classes throughout odata.py, providing more meaningful error messages and subcodes for validation and metadata errors. [1] [2] [3] [4] [5]
  • Improved HTTP error handling in _request to extract error details from responses and map status codes to subcodes, with better transient error detection and retry-after support.

Testing Improvements

  • Added tests/test_http_errors.py to verify HTTP error handling, subcode mapping, transient detection, and error detail extraction.
  • Updated tests/test_logical_crud.py to expect MetadataError instead of RuntimeError for unknown logical names, reflecting the new error handling approach. [1] [2]

Comment thread src/dataverse_sdk/errors.py
Comment thread src/dataverse_sdk/errors.py Outdated
Comment thread src/dataverse_sdk/odata.py Outdated
Comment thread src/dataverse_sdk/odata.py Outdated
@tpellissier-msft tpellissier-msft merged commit 77c4489 into main Oct 22, 2025
3 checks passed
@zhaodongwang-msft zhaodongwang-msft deleted the user/tpellissier/structured-errors-2 branch February 13, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants