Sha256: f9a367066601ad36af536974afbe2ed378dcc8815180f6daed16d1239bf1a485

Contents?: true

Size: 658 Bytes

Versions: 18

Compression:

Stored size: 658 Bytes

Contents

module Agx
  class Error < StandardError
    attr_reader :title, :detail, :body, :raw_body, :status_code

    def initialize(message = "", params = {})
      @title       = params[:title]
      @detail      = message
      @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

18 entries across 18 versions & 1 rubygems

Version Path
agx-0.3.2 lib/agx/error.rb
agx-0.3.1 lib/agx/error.rb
agx-0.3.0 lib/agx/error.rb
agx-0.2.9 lib/agx/error.rb
agx-0.2.8 lib/agx/error.rb
agx-0.2.7 lib/agx/error.rb
agx-0.2.6 lib/agx/error.rb
agx-0.2.5 lib/agx/error.rb
agx-0.2.4 lib/agx/error.rb
agx-0.2.3 lib/agx/error.rb
agx-0.2.2 lib/agx/error.rb
agx-0.2.0 lib/agx/error.rb
agx-0.1.5 lib/agx/error.rb
agx-0.1.4 lib/agx/error.rb
agx-0.1.3 lib/agx/error.rb
agx-0.1.2 lib/agx/error.rb
agx-0.1.1 lib/agx/error.rb
agx-0.1.0 lib/agx/error.rb