Exception: Alman::ApiError
Instance Attribute Summary collapse
Attributes inherited from AlmanError
#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/alman/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/alman/errors/api_error.rb', line 3
def api_method
@api_method
end
|
Instance Method Details
#body ⇒ Object
14
15
16
|
# File 'lib/alman/errors/api_error.rb', line 14
def body
@api_method.response_body if @api_method
end
|
#code ⇒ Object
10
11
12
|
# File 'lib/alman/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
25
26
27
|
# File 'lib/alman/errors/api_error.rb', line 18
def json
begin
if @api_method
hash = @api_method.response_json
return ApiObject.construct(hash)
end
rescue ApiError
nil
end
end
|
#to_s ⇒ Object
29
30
31
32
|
# File 'lib/alman/errors/api_error.rb', line 29
def to_s
prefix = code.nil? ? "" : "(Status #{code}) "
"#{prefix}#{@message}"
end
|