Sha256: 5cd62281b02713ae58a5ee98f8d895996dcb0dea95286732803d374585346fd8

Contents?: true

Size: 491 Bytes

Versions: 19

Compression:

Stored size: 491 Bytes

Contents

# encoding: utf-8

require 'faraday'
require 'nimbu-api/errors'

module Nimbu
  class Response::RaiseError < Faraday::Response::Middleware

    def on_complete(env)
      status_code = env[:status].to_i
      service_error = Nimbu::Error::ServiceError
      error_class = service_error.errors[status_code]
      error_class = service_error if !error_class and (400...600).include? status_code
      raise error_class.new(env) if error_class
    end

  end # Response::RaiseError
end # Nimbu

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
nimbu-api-0.5.0 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.4.4 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.4.3 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.4.2 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.4.1 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.4.0 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.3.0 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.2.1 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.2 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.2.beta.3 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.2.beta.2 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.2.beta.1 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.2.beta lib/nimbu-api/response/raise_error.rb
nimbu-api-0.1.5 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.1.4 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.1.3 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.1.1 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.1 lib/nimbu-api/response/raise_error.rb
nimbu-api-0.0.2 lib/nimbu-api/response/raise_error.rb