Sha256: b1bd6ed8efacd760ae858109721b4aafda899eb537bf6fd8b74caf5af6421437

Contents?: true

Size: 678 Bytes

Versions: 22

Compression:

Stored size: 678 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 = JSON.parse(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

22 entries across 22 versions & 1 rubygems

Version Path
flipper-1.0.0 lib/flipper/adapters/http/error.rb
flipper-1.0.0.pre lib/flipper/adapters/http/error.rb
flipper-0.28.3 lib/flipper/adapters/http/error.rb
flipper-0.28.2 lib/flipper/adapters/http/error.rb
flipper-0.28.1 lib/flipper/adapters/http/error.rb
flipper-0.28.0 lib/flipper/adapters/http/error.rb
flipper-0.27.1 lib/flipper/adapters/http/error.rb
flipper-0.27.0 lib/flipper/adapters/http/error.rb
flipper-0.26.2 lib/flipper/adapters/http/error.rb
flipper-0.26.1 lib/flipper/adapters/http/error.rb
flipper-0.26.0 lib/flipper/adapters/http/error.rb
flipper-0.26.0.rc2 lib/flipper/adapters/http/error.rb
flipper-0.26.0.rc1 lib/flipper/adapters/http/error.rb
flipper-0.25.4 lib/flipper/adapters/http/error.rb
flipper-0.25.3 lib/flipper/adapters/http/error.rb
flipper-0.25.2 lib/flipper/adapters/http/error.rb
flipper-0.25.1 lib/flipper/adapters/http/error.rb
flipper-0.25.0 lib/flipper/adapters/http/error.rb
flipper-0.24.1 lib/flipper/adapters/http/error.rb
flipper-0.24.0 lib/flipper/adapters/http/error.rb