Exception: Paid::APIError
Instance Attribute Summary collapse
Attributes inherited from PaidError
#message
Instance Method Summary
collapse
Constructor Details
#initialize(message = nil, api_method = nil) ⇒ APIError
Returns a new instance of APIError.
5
6
7
8
|
# File 'lib/paid/errors/api_error.rb', line 5
def initialize(message=nil, api_method=nil)
@message = message
@api_method = api_method
end
|
Instance Attribute Details
#api_method ⇒ Object
Returns the value of attribute api_method.
3
4
5
|
# File 'lib/paid/errors/api_error.rb', line 3
def api_method
@api_method
end
|
Instance Method Details
#body ⇒ Object
14
15
16
|
# File 'lib/paid/errors/api_error.rb', line 14
def body
@api_method.response_body if @api_method
end
|
#code ⇒ Object
10
11
12
|
# File 'lib/paid/errors/api_error.rb', line 10
def code
@api_method.response_code if @api_method
end
|
#json ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/paid/errors/api_error.rb', line 18
def json
begin
@api_method.response_json if @api_method
rescue APIError
nil
end
end
|
#to_s ⇒ Object
26
27
28
29
30
|
# File 'lib/paid/errors/api_error.rb', line 26
def to_s
prefix = code.nil? ? "" : "(Status #{code}) "
suffix = " JSON: #{JSON.pretty_generate(json)}" if json
"#{prefix}#{@message}" + (json ? suffix : "")
end
|