module BreweryDB
  module Middleware
    class ErrorHandler < Faraday::Response::Middleware
      def on_complete(env)
        case env[:status]
          when 200
          when 400 then raise BadRequest.new(env[:body].error_message)
          when 404 then raise NotFound.new(env[:body].error_message)
          else raise Error.new(env[:status])
        end
      end
    end
  end
end

module BreweryDB
  module Middleware
    class ErrorHandler < Faraday::Response::Middleware
      def on_complete(env)
        case env[:status]
          when 200
          when 400 then raise BadRequest.new(env[:body].error_message)
          when 404 then raise NotFound.new(env[:body].error_message)
          else raise Error.new(env[:status].to_s)
        end
      end
    end
  end
end

Fix failing error handler specs under Ruby 1.9.2.
Fix failing error handler specs under Ruby 1.9.2.
