Sha256: fd31076227cb5a0478e6c05c7e83b7c182ae17891c2e594b777773c2361cf372

Contents?: true

Size: 424 Bytes

Versions: 8

Compression:

Stored size: 424 Bytes

Contents

# frozen_string_literal: true

module Vertebrae
  class ResponseError < StandardError
    attr_reader :status_code

    def initialize(status_code, response)
      @status_code = status_code
      super(error_message(response))
    end

    private

    def error_message(response)
      "#{response[:method].to_s.upcase} #{response[:url]}: #{response[:status]} \n\n #{response[:body] if response[:body]}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vertebrae-0.8.0 lib/vertebrae/response_error.rb
vertebrae-1.0.5 lib/vertebrae/response_error.rb
vertebrae-1.0.4 lib/vertebrae/response_error.rb
vertebrae-1.0.2 lib/vertebrae/response_error.rb
vertebrae-1.0.1 lib/vertebrae/response_error.rb
vertebrae-1.0.0 lib/response_error.rb
vertebrae-0.7.0 lib/response_error.rb
vertebrae-0.6.2 lib/response_error.rb