-
Notifications
You must be signed in to change notification settings - Fork 762
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
Unify log messages & 404 detection approach #142
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.
Overall LGTM, just made some minor comments/suggestions/inquiries.
d.SetId("") | ||
return nil | ||
if err, ok := err.(*github.ErrorResponse); ok { | ||
if err.Response.StatusCode == 404 { |
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.
nitpick: prefer http.StatusNotFound over hardcoding http response codes.
I actually meant the whole block, error cast, 404 check, and then print
message. Like i said though its no biggie
…On Fri, Aug 31, 2018, 11:55 AM Radek Simko, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In github/resource_github_user_gpg_key.go
<https://github.com/terraform-providers/terraform-provider-github/pull/142#discussion_r214399499>
:
> key, _, err := client.Users.GetGPGKey(context.TODO(), id)
if err != nil {
- log.Printf("[WARN] GitHub User GPG Key (%s) not found, removing from state", d.Id())
- d.SetId("")
- return nil
+ if err, ok := err.(*github.ErrorResponse); ok {
I'm torn on that... I see your point, but at the same time it wouldn't
save a single LOC, just a few characters 🤔
We still need both variables, so effectively you'd end up with something
like
if err, ok := tryCastingToGithubError(err); ok {
the logic we'd decouple would be just attempt to cast the error, so I see
very little benefit in decoupling it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/terraform-providers/terraform-provider-github/pull/142#discussion_r214399499>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AjIEHVuSyOg1fu0RJgzZk_QjOzH9d5L5ks5uWVx_gaJpZM4WVbY->
.
|
3386a10
to
2330b0d
Compare
Right, that's intentionally verbose for now, because I'm lining up another PR which will add another check for |
…ation Unify log messages & 404 detection approach
The two failures are a result of eventually consistent API, at least I can see these failing on
master
too currently.