-
Notifications
You must be signed in to change notification settings - Fork 372
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
Add new exception types for HTTP status 405 and 412 #1148
Conversation
Thanks for putting this up @mweigel ! I'll need some time to fully review it as I have a busy couple of weeks ahead. One thing I should have mentioned in the original issue, is that while we can introduce the new exceptions in a minor release, we can't update the status map until a major release. The reason is that if people have code that is expecting to catch So I think we should split the PR; the new exception classes are introduced in the next (minor) release, and that lets folks update their Does that make sense to you? |
* Prepare for hvac#1093 by adding PreconditionFailed exception for status code 412 * Add UnsupportedOperation exception for status code 405
fc6c8e5
to
5dc203f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1148 +/- ##
==========================================
+ Coverage 87.66% 87.68% +0.01%
==========================================
Files 66 66
Lines 3227 3231 +4
==========================================
+ Hits 2829 2833 +4
Misses 398 398
|
Yes, that makes sense. I was originally thinking the change wouldn't be merged until 3.0.0. I've reverted the changes to the status map and tests. |
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.
I want to edit the PR description as a signpost for people reading the changelog, to give instructions on what to do before merging, but this will bein the next release, thank you!
@mweigel if you wouldn't mind also submitting the PR containing the status map changes and tests, that would be great, that way we have it prepared and reviewed and ready for 3.0.0. |
Cool, pushed #1149 |
HTTP exception type changes
Any HTTP exception in
hvac
which does not have a pre-existing mapped status code to exception will return anUnexpectedError
exeption.We would like to add exception types for status codes 412 (
PreconditionFailed
) and 405 (UnsupportedOperation
).Breaking change
Existing code that wants to catch those exceptions may be written similarly to this:
If we then map those status codes to new exception types, the above code will fail to catch them.
As a result, we will do this change in two stages:
hvac
2.2.0.hvac
3.0.0 and will map the status codes.Action needed
If you currently use
UnexpectedError
to catch status codes 405 or 412, update your code before v3.0.0 to something like the following (usingUnsupportedOperation
as the example):or if you want to handle them differently:
This ensures that your code is ready to handle the new exception type. This is especially important if your project intends to support multiple major versions of
hvac
.Future exception types
If you are using
UnexpectedError
as a catch-all for any exception without a dedicated type, and you want to future proof against more HTTP exception types being added in the future, you may consider catching the base classVaultError
instead or in addition to `:412
#1093 by adding PreconditionFailed exception for status code 412Adding the UnsupportedOperation exception is a reasonably significant change as there might be quite a bit of code expecting UnexpectedError on a 405. Can take it out if it's too much.