Class: PR::Pin::API::Error

Inherits:
Error
  • Object
show all
Defined in:
lib/pr/pin/api/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ Error

Returns a new instance of Error.



7
8
9
10
11
12
# File 'lib/pr/pin/api/error.rb', line 7

def initialize(error)
  @response = error.response
  @result = error.result

  super(error.message)
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/pr/pin/api/error.rb', line 5

def response
  @response
end

#resultObject (readonly)

Returns the value of attribute result.



5
6
7
# File 'lib/pr/pin/api/error.rb', line 5

def result
  @result
end

Instance Method Details

#codeObject



22
23
24
# File 'lib/pr/pin/api/error.rb', line 22

def code
  result[:error]
end

#descriptionObject



26
27
28
# File 'lib/pr/pin/api/error.rb', line 26

def description
  result[:error_description]
end

#error?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/pr/pin/api/error.rb', line 38

def error?
  true
end

#inspectObject



42
43
44
# File 'lib/pr/pin/api/error.rb', line 42

def inspect
  "#<#{self.class} - Status: `#{response_code}', Code: `#{code}', Message: `#{description}'>"
end

#messagesObject



30
31
32
# File 'lib/pr/pin/api/error.rb', line 30

def messages
  result.fetch(:messages, [])
end

#response_codeObject



14
15
16
# File 'lib/pr/pin/api/error.rb', line 14

def response_code
  response.code
end

#success?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/pr/pin/api/error.rb', line 34

def success?
  false
end

#to_hObject



18
19
20
# File 'lib/pr/pin/api/error.rb', line 18

def to_h
  result
end