-
Notifications
You must be signed in to change notification settings - Fork 4
feat: wrap exceptions thrown while authenticating #42
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves error handling in the authentication process and enhances test coverage in the client module.
- Replaces an incorrect return statement with raise for proper exception propagation.
- Adds try-except handling in the authenticate method to raise a DiodeConfigError on failure.
- Introduces a new test to validate exception handling during authentication requests.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| netboxlabs/diode/sdk/client.py | Updates exception handling in both ingest and authenticate methods. |
| tests/test_client.py | Adds a new test for request exceptions and includes minor formatting adjustments. |
leoparente
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
mfiedorowicz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This pull request includes improvements to error handling and test coverage in the
netboxlabs/diode/sdk/client.pyfile and its associated tests. The most important changes include replacing areturnstatement with araisestatement for consistency, adding exception handling during authentication, and introducing a new test to validate error handling for connection exceptions.Error handling improvements:
return RuntimeErrorwithraise RuntimeErrorin theingestmethod to ensure proper exception handling. (netboxlabs/diode/sdk/client.py, netboxlabs/diode/sdk/client.pyL240-R240)try-exceptblock in theauthenticatemethod to handle exceptions during the HTTP request and raise aDiodeConfigErrorwith a meaningful message. (netboxlabs/diode/sdk/client.py, netboxlabs/diode/sdk/client.pyR292-R296)Test coverage enhancements:
test_diode_authentication_request_exception, to verify that an exception during the HTTP request in theauthenticatemethod raises aDiodeConfigErrorwith the correct error message. (tests/test_client.py, tests/test_client.pyR616-R633)tests/test_client.py, tests/test_client.pyR591)