Exception: RegApi2::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/reg_api2/api_error.rb

Overview

API Error from REG.API provider. Please refer to common error codes.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, description, params) ⇒ ApiError

Returns a new instance of ApiError.



13
14
15
16
17
# File 'lib/reg_api2/api_error.rb', line 13

def initialize code,  description, params
  super code
  @description = description
  @params = params ||  {}
end

Instance Attribute Details

#descriptionString (readonly)

Returns Localized error description.

Returns:

  • (String)

    Localized error description.



8
9
10
# File 'lib/reg_api2/api_error.rb', line 8

def description
  @description
end

#paramsHash (readonly)

Returns Optional error params.

Returns:

  • (Hash)

    Optional error params.



11
12
13
# File 'lib/reg_api2/api_error.rb', line 11

def params
  @params
end

Class Method Details

.from_json(json) ⇒ ApiError

Extracts error arguments from specified json.

Parameters:

  • json (Hash)

Returns:

  • (ApiError)

    Initialized error object.



22
23
24
25
26
27
28
# File 'lib/reg_api2/api_error.rb', line 22

def self.from_json json
  new(
    json['error_code'],
    json['error_text'],
    json['error_params']
  )
end