Exception: FlatApi::FlatError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status: nil, code: nil, request_id: nil, headers: nil, body: nil) ⇒ FlatError

Returns a new instance of FlatError.



14
15
16
17
18
19
20
21
22
# File 'lib/flat_api/errors.rb', line 14

def initialize(message, status: nil, code: nil, request_id: nil, headers: nil, body: nil)
  super(message)
  @status = status
  @code = code
  # Present only for internal and backend errors, so treat it as optional.
  @request_id = request_id
  @headers = headers || {}
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



12
13
14
# File 'lib/flat_api/errors.rb', line 12

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



12
13
14
# File 'lib/flat_api/errors.rb', line 12

def code
  @code
end

#headersObject (readonly)

Returns the value of attribute headers.



12
13
14
# File 'lib/flat_api/errors.rb', line 12

def headers
  @headers
end

#request_idObject (readonly)

Returns the value of attribute request_id.



12
13
14
# File 'lib/flat_api/errors.rb', line 12

def request_id
  @request_id
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/flat_api/errors.rb', line 12

def status
  @status
end

Instance Method Details

#to_sObject



24
25
26
27
28
29
30
# File 'lib/flat_api/errors.rb', line 24

def to_s
  parts = [super]
  parts << "code=#{code}" if code
  parts << "status=#{status}" if status
  parts << "id=#{request_id}" if request_id
  parts.join(' ')
end