Exception: Pipl::Client::APIError

Inherits:
Exception
  • Object
show all
Defined in:
lib/pipl/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code) ⇒ APIError

Returns a new instance of APIError.



11
12
13
14
# File 'lib/pipl/errors.rb', line 11

def initialize(message, status_code)
  super message
  @status_code = status_code
end

Instance Attribute Details

#status_codeObject (readonly)

Returns the value of attribute status_code.



9
10
11
# File 'lib/pipl/errors.rb', line 9

def status_code
  @status_code
end

Class Method Details

.from_json(json_str) ⇒ Object



24
25
26
27
# File 'lib/pipl/errors.rb', line 24

def self.from_json(json_str)
  h = JSON.parse(json_str, symbolize_names: true)
  self.new(h[:error], h[:@http_status_code])
end

Instance Method Details

#is_pipl_error?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/pipl/errors.rb', line 20

def is_pipl_error?
  not is_user_error?
end

#is_user_error?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/pipl/errors.rb', line 16

def is_user_error?
  (400..499).member?(@status_code)
end