Exception: Pliny::Errors::Error

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

Direct Known Subclasses

HTTPStatusError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, id) ⇒ Error

Returns a new instance of Error.



14
15
16
17
# File 'lib/pliny/errors.rb', line 14

def initialize(message, id)
  @id = id
  super(message)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/pliny/errors.rb', line 6

def id
  @id
end

Class Method Details

.render(error) ⇒ Object



8
9
10
11
12
# File 'lib/pliny/errors.rb', line 8

def self.render(error)
  headers = { "content-type" => "application/json; charset=utf-8" }
  data = { id: error.id, message: error.message }
  [error.status, headers, [JSON.generate(data)]]
end