-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Debugging clearbit errors in our code has become a nightmare. This is what it looks like in our logs:
ERROR: clearbit:
Manually debugging, I've realized that this is because the API is returning codes like 404 or 422.
Internally, we end up wrapping the errors with github.com/pkg/errors and having to return different types of errors:
res, resp, err := s.ClearbitClient.Person.FindCombined(clearbit.PersonFindParams{
Email: r.Email,
})
if resp.StatusCode == 202 {
// Deferred
return r, errTryAgainLater
} else if resp.StatusCode == 404 {
return r, errEmailNotFound
} else if resp.StatusCode == 422 {
return r, errInvalid
} else if err != nil {
return r, errors.Wrap(err, fmt.Sprintf("code %d", r.StatusCode))
}I propose that this package either (1) has named error types that it returns (e.g. ErrNotFound), or that it at least wraps all errs with the API response status code.
Metadata
Metadata
Assignees
Labels
No labels