Sha256: 4c924c212b30ff0f869e4430754c2b2ab191b707dcf6dfc4670f3838bdc55bb8

Contents?: true

Size: 545 Bytes

Versions: 23

Compression:

Stored size: 545 Bytes

Contents

module Katapaty
  class JsonResponseError < StandardError; end

  class ResponseError < StandardError
    attr_reader :data_type
    attr_reader :data_args
    attr_reader :data_message
    attr_reader :code
    attr_reader :message_class

    def initialize(json)
      @message_class, @code = json['message'], json['code']
      json['data'].each_pair do |(k,v)|
        instance_variable_set '@data_%s' % k, v
      end if json.has_key? 'data'
      super
    end

    def message
      "#{@message_class}:#{@data_message}"
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
katapaty-1.1.1 lib/katapaty/errors.rb
katapaty-1.1.0 lib/katapaty/errors.rb
katapaty-1.0.6 lib/katapaty/errors.rb
katapaty-1.0.5 lib/katapaty/errors.rb
katapaty-1.0.4 lib/katapaty/errors.rb
katapaty-1.0.3 lib/katapaty/errors.rb
katapaty-1.0.2 lib/katapaty/errors.rb
katapaty-1.0.1 lib/katapaty/errors.rb
katapaty-1.0.0 lib/katapaty/errors.rb
katapaty-0.5.1 lib/katapaty/errors.rb
katapaty-0.5.0 lib/katapaty/errors.rb
katapaty-0.4.4 lib/katapaty/errors.rb
katapaty-0.4.3 lib/katapaty/errors.rb
katapaty-0.4.1 lib/katapaty/errors.rb
katapaty-0.4.0 lib/katapaty/errors.rb
katapaty-0.3.5 lib/katapaty/errors.rb
katapaty-0.3.4 lib/katapaty/errors.rb
katapaty-0.3.3 lib/katapaty/errors.rb
katapaty-0.3.2 lib/katapaty/errors.rb
katapaty-0.3.1 lib/katapaty/errors.rb