Skip to content
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

Remove ErrorResponse type #313

Open
displague opened this issue Nov 27, 2021 · 2 comments
Open

Remove ErrorResponse type #313

displague opened this issue Nov 27, 2021 · 2 comments

Comments

@displague
Copy link
Member

Tthe ErrorResponse type copies the http.Response unnecessarily since all packngo API methods return both an error and the http.Response.

A more fitting error type would be one that simplifies the single and multiple errors returned from the Equinix Metal API. This could be done with a packngo.Error type (effectively ErrorResponse, without embedding *http.Response)

One missed advantage of the ErrorResponse type is that http.Response was embedded instead of packngo.Response (which offers insight into Equinix Metal API rate-limits).

In retrospect, I think it may have been a better pattern to return (for example) Devices.List() ([]Device, *packngo.Response, error) (with the error being an packngo.Error in most cases).

@displague
Copy link
Member Author

@displague
Copy link
Member Author

In Terraform, an ErrorResponse type was created mimicking the packngo.ErrorResponse type. This has created difficulty in handling errors (as expressed in the comments listed above).

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

No branches or pull requests

1 participant