class DataComApi::Error

Constants

API_ERROR_CODE
API_HTTP_STATUS_CODE
API_LIMIT_EXCEEDED_MSG

Attributes

api_stack_trace[R]
error_code[R]
http_status_code[R]

Public Class Methods

from_code(error_code_str) click to toggle source
# File lib/data-com-api/errors.rb, line 29
def self.from_code(error_code_str)
  case error_code_str
  when ParamError::API_ERROR_CODE             then ParamError
  when LoginFailError::API_ERROR_CODE         then LoginFailError
  when TokenFailError::API_ERROR_CODE         then TokenFailError
  when PurchaseLowPointsError::API_ERROR_CODE then PurchaseLowPointsError
  when ContactNotExistError::API_ERROR_CODE   then ContactNotExistError
  when ContactNotOwnedError::API_ERROR_CODE   then ContactNotOwnedError
  when SearchError::API_ERROR_CODE            then SearchError
  when SysError::API_ERROR_CODE               then SysError
  when NotImplementedError::API_ERROR_CODE    then NotImplementedError
  when NotAvailableError::API_ERROR_CODE      then NotAvailableError
  else Error
  end
end
new(msg=nil, options={}) click to toggle source
Calls superclass method
# File lib/data-com-api/errors.rb, line 15
def initialize(msg=nil, options={})
  options = options.reverse_merge({
    http_status_code: nil,
    api_stack_trace:  nil,
    error_code:       nil
  })

  @http_status_code ||= options[:http_status_code] || self.class::API_HTTP_STATUS_CODE
  @api_stack_trace  ||= options[:api_stack_trace]
  @error_code       ||= options[:error_code] || self.class::API_ERROR_CODE

  super(msg)
end