Update APIError.Error() to provide more helpful error messages #334
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While refactoring the API handling with the
APIError
type, we gave callersmore capability to inspect the errors that come from the API so that we can
handle them. Unfortunately, in the process we lost some fidelity in the strings
returned by its
Error()
method, compared to how errors used to be handled.This updates the
APIError.Error()
method to now include the first detailederror string provided from the API, if there is one, and incidate how many more
existed in the response (without printing them). This should help keep the error
tidy, while making it actionable by consumers. Consumers of this package are
still encouraged to deeply inspect the error, to handle each one.
This was inspired by #327, which the reporter closed after learning how to
deeply inspect the returned error value.