nateleavitt / infusionsoft

Ruby Gem for the Infusionsoft API
MIT License
58 stars 63 forks source link

Non-200 Infusionsoft API responses aren't being logged #77

Closed jasonpau closed 2 years ago

jasonpau commented 3 years ago

When a request to the Infusionsoft API returns something other than a 200 response, we aren't able to determine the reason for the error as the response code/body isn't being logged:

In another non-Rails application we maintain, we log the failing Infusionsoft API response code/body as those can be helpful. I.e. 401 Unauthorized when a token is invalid, or seeing a 404 if we try to update a non-existent contact, or a 500 error if it's an issue on Infusionsoft's side (which we've encountered before).

Even something as simple as logging the err object would go a long way in helping us when it comes to troubleshooting issues with the Infusionsoft API. E.g.:

# https://github.com/nateleavitt/infusionsoft/blob/master/lib/infusionsoft/request.rb#L51

      resp = RestClient::Request.execute(opts)
    rescue RestClient::ExceptionWithResponse => err
      api_logger.info "RESPONSE: #{err.inspect}"
    else

I can create a PR for this if you'd like.

nateleavitt commented 2 years ago

Hi @jasonpau sorry for the late response. Would love a pull request.

jasonpau commented 2 years ago

@nateleavitt I created a PR (#81) for this.

nateleavitt commented 2 years ago

Okay.. it has been merged. Thank you!