-
Notifications
You must be signed in to change notification settings - Fork 366
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
refactor: success predicates for rest_internal::RestResponse
#10370
refactor: success predicates for rest_internal::RestResponse
#10370
Conversation
We often need to determine if a `RestResponse` contains a successful HTTP response or an error. These helpers make the code easier to read and provide more consistent treatment of `RestResponse`. Callers that deviate from the standard success/failure codes can write their own functions (e.g., GCS treats 308 as "success" in some RPCs).
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
Codecov ReportBase: 93.85% // Head: 93.86% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #10370 +/- ##
=======================================
Coverage 93.85% 93.86%
=======================================
Files 1600 1600
Lines 145418 145421 +3
=======================================
+ Hits 136485 136501 +16
+ Misses 8933 8920 -13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
bool IsHttpSuccess(RestResponse const& response) { | ||
static_assert(HttpStatusCode::kMinSuccess < HttpStatusCode::kMinNotSuccess, | ||
"Invalid HTTP code success range"); | ||
return response.StatusCode() <= HttpStatusCode::kMinNotSuccess && |
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.
It feels like either kMinNotSuccess
is lying, or that should be `<'. That is, "== kMinNotSuccess" shouldn't be a success. (??)
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.
Good catch, fixed.
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
/gcbrun |
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
We often need to determine if a
RestResponse
contains a successful HTTP response or an error. These helpers make the code easier to read and provide more consistent treatment ofRestResponse
. Callers that deviate from the standard success/failure codes can write their own functions (e.g., GCS treats 308 as "success" in some RPCs).Part of the work for #5915
This change is