Exception: Dato::ApiError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ApiError

Returns a new instance of ApiError.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dato/api_error.rb', line 7

def initialize(response)
  body = JSON.parse(response[:body]) if response[:body]

  message = [
    "DatoCMS API Error",
    "Status: #{response[:status]}",
    "Response:",
    JSON.pretty_generate(body),
  ].join("\n")

  super(message)

  @response = response
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/dato/api_error.rb', line 5

def body
  @body
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/dato/api_error.rb', line 5

def response
  @response
end