Sha256: 2a6888ec4482c000de47febe5aa0f135d86ffb426f3b6303b49ab37d21eb904c

Contents?: true

Size: 432 Bytes

Versions: 7

Compression:

Stored size: 432 Bytes

Contents

require 'faraday'
require 'oktakit/error'

module Oktakit
  # Faraday response middleware
  module Response
    # This class raises an Oktakit-flavored exception based
    # HTTP status codes returned by the API
    class RaiseError < Faraday::Response::Middleware
      private

      def on_complete(response)
        if error = Oktakit::Error.from_response(response)
          raise error
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
oktakit-0.2.0 lib/oktakit/response/raise_error.rb
oktakit-0.1.5 lib/oktakit/response/raise_error.rb
oktakit-0.1.4 lib/oktakit/response/raise_error.rb
oktakit-0.1.3 lib/oktakit/response/raise_error.rb
oktakit-0.1.2 lib/oktakit/response/raise_error.rb
oktakit-0.1.1 lib/oktakit/response/raise_error.rb
oktakit-0.1.0 lib/oktakit/response/raise_error.rb