Module: RecurlyApi::ExceptionHandler
- Included in:
- Client
- Defined in:
- lib/recurly_api/exception_handler.rb
Overview
Handles all possible exceptions that are returned by RestClient and Recurly Server and logs everything
Instance Method Summary collapse
Instance Method Details
#recurly_api_exception_handler(&block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/recurly_api/exception_handler.rb', line 7 def recurly_api_exception_handler(&block) # block.call yield rescue RestClient::Unauthorized, RestClient::Forbidden => e # https://www.rubydoc.info/gems/rest-client/1.6.7/frames#label-Result+handling logger.error("#{logger_heading} ERROR: Access denied to Recurly API") handle_recurly_error_response(e.response) rescue RestClient::ImATeapot => e logger.error("#{logger_heading} ERROR: Recurly Server is a teapot! # RFC 2324") handle_recurly_error_response(e.response) rescue RestClient::MovedPermanently, RestClient::Found, RestClient::TemporaryRedirect => e logger.error("#{logger_heading} ERROR: Follow redirection- #{e.response.follow_redirection}") handle_recurly_error_response(e.response) rescue RestClient::ExceptionWithResponse => e logger.error("#{logger_heading} ERROR: RestClient::ExceptionWithResponse") handle_recurly_error_response(e.response) rescue RestClient::Exception => e logger.error("#{logger_heading} ERROR: RestClient::Exception") handle_recurly_error_response(e.response) # rescue StandardError => e # Note: don't rescue standard error # logger.error("#{logger_heading} ERROR: Internal Server Error") # # e.backtrace.join("\n ") # raise e.message end |