chargebee / chargebee-ruby

Ruby library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=ruby
MIT License
32 stars 60 forks source link

only rescue RestClient exceptions #16

Open igneus opened 8 years ago

igneus commented 8 years ago

Currently all errors coming from the depths of rest-client are rescued and translated to IOError. I suggest to change it:

  1. It's a bad practice to rescue Exception. If you want to rescue all exceptions, rescue StandardError. Here's why.
  2. As in the scenario described in #15, an error may occasionally happen somewhere deep in rest-client, that has nothing to do with network communication, but results solely from gems incompatibility or other client-side software misfortune. It is really misleading to mask such errors as IOError.

I believe the right thing to do is to only handle exceptions raised by rest-client (which fortunately have a common ancestor RestClient::Exception). rest-client already does an awesome job handling various exceptions from the layers below and translating them to instances of it's own exception types, so you can be assured that exceptions of other types aren't "mere IO errors" and signal deeper problems.

evolve2k commented 4 years ago

One line code change to improve error handling. Looks good to me. Ship it!

jongbeau commented 3 years ago

@cb-navaneedhan - can this get merged?

sobrinho commented 8 months ago

@cb-nithins can we merge this one?