Sha256: a387ce9902e17110dd6520f102b519b488f49c00e39f00dbb22b86db76e2f39a

Contents?: true

Size: 682 Bytes

Versions: 7

Compression:

Stored size: 682 Bytes

Contents

module VismaEaccounting
  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

7 entries across 7 versions & 1 rubygems

Version Path
visma_eaccounting-0.1.0 lib/visma_eaccounting/api_error.rb
visma_eaccounting-0.0.7 lib/visma_eaccounting/api_error.rb
visma_eaccounting-0.0.6 lib/visma_eaccounting/api_error.rb
visma_eaccounting-0.0.5 lib/visma_eaccounting/api_error.rb
visma_eaccounting-0.0.4 lib/visma_eaccounting/api_error.rb
visma_eaccounting-0.0.3 lib/visma_eaccounting/api_error.rb
visma_eaccounting-0.0.2 lib/visma_eaccounting/api_error.rb