Sha256: c0881da5435ca24e07507034386705d84e57f0e9dd08f83c4ee899a6efd9fc78

Contents?: true

Size: 675 Bytes

Versions: 5

Compression:

Stored size: 675 Bytes

Contents

module Confrater
  class APIError < StandardError
    attr_reader :title, :detail, :body, :raw_body, :status_code

    def initialize(message = "", params = {})
      @title       = params[:title]
      @detail      = params[:detail]
      @body        = params[:body]
      @raw_body    = params[:raw_body]
      @status_code = params[:status_code]

      super(message)
    end

    def to_s
      super + " " + instance_variables_to_s
    end

    private

    def instance_variables_to_s
      [:title, :detail, :body, :raw_body, :status_code].map do |attr|
        attr_value = send(attr)

        "@#{attr}=#{attr_value.inspect}"
      end.join(", ")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
confrater-0.0.6 lib/confrater/api_error.rb
confrater-0.0.5 lib/confrater/api_error.rb
confrater-0.0.4 lib/confrater/api_error.rb
confrater-0.0.3 lib/confrater/api_error.rb
confrater-0.0.2 lib/confrater/api_error.rb