class TwelvedataRuby::ResponseError

Constants

API_ERROR_CODES_MAP
HTTP_ERROR_CODES_MAP

Attributes

code[R]
json[R]
request[R]

Public Class Methods

error_code_klass(code, error_type=:api) click to toggle source
# File lib/twelvedata_ruby/error.rb, line 58
def self.error_code_klass(code, error_type=:api)
  error_type = :api unless %i[api http].member?(error_type)

  TwelvedataRuby::ResponseError.const_get("#{error_type.upcase}_ERROR_CODES_MAP")[code]
end
new(json:, request:, attrs: nil, message: nil, code: nil) click to toggle source
Calls superclass method TwelvedataRuby::Error::new
# File lib/twelvedata_ruby/error.rb, line 66
def initialize(json:, request:, attrs: nil, message: nil, code: nil)
  @json = json.is_a?(Hash) ? json : {}
  @code = code || @json[:code]
  @attrs = attrs || {}
  @request = request
  super(attrs: @attrs, message: "#{@json[:message] || message}")
end