Exception: VatNumberValidator::APIError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/vat_number_validator/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ APIError

Returns a new instance of APIError.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vat_number_validator/errors.rb', line 3

def initialize(result)
  code = result['error']['code']
  message = case code
            when 101
              'invalid/missing access_key'
            when 104
              'usage limit reached'
            when 105
              'https access restricted'
            when 102
              'inactive user'
            else
              "vatlayer API error code #{code}"
            end
  super(message)
end