Skip to content

fix[#285]: change APIError to use pointer receiver#298

Merged
nfx merged 1 commit intodatabricks:mainfrom
amwill04:aw-apierror-pointer
Feb 3, 2023
Merged

fix[#285]: change APIError to use pointer receiver#298
nfx merged 1 commit intodatabricks:mainfrom
amwill04:aw-apierror-pointer

Conversation

@amwill04
Copy link
Copy Markdown
Contributor

@amwill04 amwill04 commented Feb 3, 2023

Allows APIError to be used as expected with errors.As. Closes #285.

Allows APIError to be used as expected with `errors.As`
@nfx nfx requested review from nfx and pietern February 3, 2023 16:35
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Base: 40.84% // Head: 40.87% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (222f2c2) compared to base (831702b).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #298      +/-   ##
==========================================
+ Coverage   40.84%   40.87%   +0.02%     
==========================================
  Files          46       46              
  Lines        2661     2662       +1     
==========================================
+ Hits         1087     1088       +1     
  Misses       1485     1485              
  Partials       89       89              
Impacted Files Coverage Δ
client/client.go 91.53% <100.00%> (+0.04%) ⬆️

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

retry, err := apierr.CheckForRetry(ctx, response, err, responseBody.Bytes(), responseBodyErr)
if err != nil && !errors.As(err, &apierr.APIError{}) {
var apiErr *apierr.APIError
if err != nil && !errors.As(err, &apiErr) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now takes a pointer to a pointer. I don't understand why this is necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look at the linked issue first.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the linked documentation that shows defining a pointer type prior to calling errors.As.

LGTM, thanks for the PR!

@nfx nfx merged commit 333e3e4 into databricks:main Feb 3, 2023
nfx added a commit that referenced this pull request Feb 17, 2023
nfx added a commit that referenced this pull request Feb 17, 2023
nfx added a commit that referenced this pull request Feb 17, 2023
 * Change APIError to use pointer receiver ([#298](#298)).
 * Drop duplicate prefix in randomized email ([#299](#299)).
 * Expand semver pattern to be compliant with https://semver.org ([#302](#302)).
 * Fix `apierr.APIError` pointer receivers ([#307](#307)).
 * Skip loading config if auth is already explicitly configured directly ([#306](#306)).
 * Sync fixes for smallest node selection from Terraform ([#301](#301)).
 * Updated from OpenAPI spec ([#305](#305)).

Dependency updates:

 * Bump google.golang.org/api from 0.109.0 to 0.110.0 ([#303](#303)).
@nfx nfx mentioned this pull request Feb 17, 2023
nfx added a commit that referenced this pull request Feb 17, 2023
* Change APIError to use pointer receiver
([#298](#298)).
* Drop duplicate prefix in randomized email
([#299](#299)).
* Expand semver pattern to be compliant with https://semver.org
([#302](#302)).
* Fix `apierr.APIError` pointer receivers
([#307](#307)).
* Skip loading config if auth is already explicitly configured directly
([#306](#306)).
* Sync fixes for smallest node selection from Terraform
([#301](#301)).
* Updated from OpenAPI spec
([#305](#305)).

Dependency updates:

* Bump google.golang.org/api from 0.109.0 to 0.110.0
([#303](#303)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

APIError not using pointer receiver

4 participants