Exception: MicroCMS::APIError

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

Overview

APIError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code:, body:) ⇒ APIError

Returns a new instance of APIError.



160
161
162
163
164
165
166
# File 'lib/microcms.rb', line 160

def initialize(status_code:, body:)
  @status_code = status_code
  @body = parse_body(body)

  message = @body['message'] || 'Unknown error occured.'
  super(message)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



158
159
160
# File 'lib/microcms.rb', line 158

def body
  @body
end

#status_codeObject

Returns the value of attribute status_code.



158
159
160
# File 'lib/microcms.rb', line 158

def status_code
  @status_code
end

Instance Method Details

#inspectObject



168
169
170
# File 'lib/microcms.rb', line 168

def inspect
  "#<#{self.class.name} @status_code=#{status_code}, @body=#{body.inspect} @message=#{message.inspect}>"
end