Exception: Agave::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/agave/api_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_error) ⇒ ApiError

Returns a new instance of ApiError.



6
7
8
# File 'lib/agave/api_error.rb', line 6

def initialize(faraday_error)
  @faraday_error = faraday_error
end

Instance Attribute Details

#faraday_errorObject (readonly)

Returns the value of attribute faraday_error.



4
5
6
# File 'lib/agave/api_error.rb', line 4

def faraday_error
  @faraday_error
end

Instance Method Details

#bodyObject



19
20
21
# File 'lib/agave/api_error.rb', line 19

def body
  JSON.parse(faraday_error.response[:body])
end

#messageObject



10
11
12
13
14
15
16
17
# File 'lib/agave/api_error.rb', line 10

def message
  [
    'AgaveCMS API Error',
    "Status: #{faraday_error.response[:status]}",
    'Response:',
    JSON.pretty_generate(body)
  ].join("\n")
end