Class: ZerigoDNS::Middleware::ErrorHandler
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- ZerigoDNS::Middleware::ErrorHandler
- Defined in:
- lib/zerigodns/middleware/error_handler.rb
Overview
Rasies exceptions on errors
Instance Method Summary collapse
-
#call(request_env) ⇒ Object
Rasies an exception on a response code that is not HTTP OK.
-
#initialize(app = nil, options = {}) ⇒ ErrorHandler
constructor
Constructs new middleware instance.
Constructor Details
#initialize(app = nil, options = {}) ⇒ ErrorHandler
Constructs new middleware instance
4 5 6 7 |
# File 'lib/zerigodns/middleware/error_handler.rb', line 4 def initialize app=nil, ={} @app = app @options = end |
Instance Method Details
#call(request_env) ⇒ Object
Rasies an exception on a response code that is not HTTP OK
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/zerigodns/middleware/error_handler.rb', line 10 def call request_env @app.call(request_env).on_complete do |response| response[:code] = ZerigoDNS::Client::ResponseCode.new(response.status) if response[:code].ok? response else raise ZerigoDNS::Client::ResponseError.new(response) end end end |