Sha256: 511f159d101f236f157ac9870b51d7166dfb7b8080d3c4e9ce2e0e7249c9833e

Contents?: true

Size: 686 Bytes

Versions: 10

Compression:

Stored size: 686 Bytes

Contents

require "json"

module Flipper
  module Adapters
    class Http
      class Error < StandardError
        attr_reader :response

        def initialize(response)
          @response = response
          message = "Failed with status: #{response.code}"

          begin
            data = Typecast.from_json(response.body)

            if error_message = data["message"]
              message << "\n\n#{data["message"]}"
            end

            if more_info = data["more_info"]
              message << "\n#{data["more_info"]}"
            end
          rescue => exception
            # welp we tried
          end

          super(message)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flipper-1.3.2 lib/flipper/adapters/http/error.rb
flipper-1.3.1 lib/flipper/adapters/http/error.rb
flipper-1.3.0 lib/flipper/adapters/http/error.rb
flipper-1.3.0.pre lib/flipper/adapters/http/error.rb
flipper-1.2.2 lib/flipper/adapters/http/error.rb
flipper-1.2.1 lib/flipper/adapters/http/error.rb
flipper-1.2.0 lib/flipper/adapters/http/error.rb
flipper-1.1.2 lib/flipper/adapters/http/error.rb
flipper-1.1.1 lib/flipper/adapters/http/error.rb
flipper-1.1.0 lib/flipper/adapters/http/error.rb