Add Comprehensive Custom Exceptions for Better Error Handling#561
Open
LifeJiggy wants to merge 7 commits intodigitalocean:mainfrom
Open
Add Comprehensive Custom Exceptions for Better Error Handling#561LifeJiggy wants to merge 7 commits intodigitalocean:mainfrom
LifeJiggy wants to merge 7 commits intodigitalocean:mainfrom
Conversation
Author
|
Hi maintainers and reviewers! Thank you for your time and consideration! |
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.
🚨 Add Comprehensive Custom Exceptions for Better Error Handling
This PR introduces a complete custom exception hierarchy for the pydo client, providing greatly improved error handling and debugging capabilities for users.
🛠️ Problem Solved
Previously, users only had access to generic
HttpResponseErrorexceptions from the underlying Azure SDK, which made it difficult to:🚀 Solution
status_codeandresponseattributes.from pydo import exceptionsprovides access to all exception types.🆕 New Exception Types
AuthenticationError(401) — Invalid API tokenPermissionDeniedError(403) — Insufficient permissionsResourceNotFoundError(404) — Resource doesn't existValidationError(400) — Bad request parametersConflictError(409) — Resource state conflictsRateLimitError(429) — API rate limit exceededServerError(5xx) — Server-side errorsServiceUnavailableError(503) — Service temporarily downDigitalOceanError— Base class for all custom exceptions🧑💻 Usage Examples
🌟 Key Features
DigitalOceanErrorfor easy catching📄 Files Changed
src/pydo/exceptions.py— Added custom exception classessrc/pydo/_patch.py— Exposed exceptions and added error handling methodREADME.md— Added exception documentation and usage examplestests/mocked/test_exceptions.py— Comprehensive test suite💥 Impact
🧪 Testing
Feedback and suggestions are welcome!