Sha256: 744fde67244565c53e45e3b922840583c6ee78ee70bc695c0613eae12d77cf63

Contents?: true

Size: 447 Bytes

Versions: 2

Compression:

Stored size: 447 Bytes

Contents

module Faraday
  class Response
    class VerifyStatus < Response::Middleware
      def on_complete(env)
        status = env[:status].to_i
        case env[:method]
        when :get
          raise LetsFreckle::FetchError, "Fetch failed, HTTP error: #{status}" unless status == 200
        when :post
          raise LetsFreckle::CreateError, "Create failed, HTTP error: #{status}" unless status == 201
        end
      end
    end
  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
letsfreckle-client-0.2.1 lib/faraday/response/verify_status.rb
letsfreckle-client-0.2.0 lib/faraday/response/verify_status.rb