Exception: DataComApi::Error
- Inherits:
-
StandardError
- Object
- StandardError
- DataComApi::Error
- Defined in:
- lib/data-com-api/errors.rb
Direct Known Subclasses
ApiLimitExceededError, ContactNotExistError, ContactNotOwnedError, LoginFailError, NotAvailableError, NotImplementedError, ParamError, PurchaseLowPointsError, SearchError, SysError, TokenFailError
Constant Summary collapse
- API_HTTP_STATUS_CODE =
0- API_ERROR_CODE =
'no error code provided'.freeze
- API_LIMIT_EXCEEDED_MSG =
'API plan limit exceeded'.freeze
Instance Attribute Summary collapse
-
#api_stack_trace ⇒ Object
readonly
Returns the value of attribute api_stack_trace.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#http_status_code ⇒ Object
readonly
Returns the value of attribute http_status_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(msg = nil, options = {}) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(msg = nil, options = {}) ⇒ Error
Returns a new instance of Error.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/data-com-api/errors.rb', line 15 def initialize(msg=nil, ={}) = .reverse_merge({ http_status_code: nil, api_stack_trace: nil, error_code: nil }) @http_status_code ||= [:http_status_code] || self.class::API_HTTP_STATUS_CODE @api_stack_trace ||= [:api_stack_trace] @error_code ||= [:error_code] || self.class::API_ERROR_CODE super(msg) end |
Instance Attribute Details
#api_stack_trace ⇒ Object (readonly)
Returns the value of attribute api_stack_trace.
12 13 14 |
# File 'lib/data-com-api/errors.rb', line 12 def api_stack_trace @api_stack_trace end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
13 14 15 |
# File 'lib/data-com-api/errors.rb', line 13 def error_code @error_code end |
#http_status_code ⇒ Object (readonly)
Returns the value of attribute http_status_code.
11 12 13 |
# File 'lib/data-com-api/errors.rb', line 11 def http_status_code @http_status_code end |
Class Method Details
.from_code(error_code_str) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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 |