Skip to content

Exceptions are not handled by NativeRequest.request #109

@mzugor

Description

@mzugor

Description

NativeRequest.request uses an empty rescue after making a request, skipping any Exception from being caught:

rescue => e
puts "[ChargeBee] HTTP request failed on attempt #{attempts}: #{e}" if enable_debug
if retry_enabled && attempts <= max_retries
retry_delay = backoff_delay(delay_ms, attempts)
sleep(retry_delay)
next
else
raise IOError.new("IO Exception when trying to connect to ChargeBee with URL #{uri} . Reason: #{e}", e)
end

The older Rest implementation however rescues an Exception just fine:

rescue Exception => e
raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)

This is a possible regression. The issue surfaced while upgrading from an older version that was still utilizing Rest behind the scenes for making requests. The upgrade resulted in some of our tests breaking with a now-unhandled error that inherits Exception directly, rather than StandardError. Previously this was all wrapped in a ChargeBee::IOError as seen above.

Expectation

NativeRequest.request should explicitly rescue Exceptions (then wrap them in the same ChargeBee::IOError).

(If the difference was intended, then please feel free to close the issue.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions