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.



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

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

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/pliny/errors.rb', line 4

def id
  @id
end

Class Method Details

.render(error) ⇒ Object



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

def self.render(error)
  headers = { "Content-Type" => "application/json; charset=utf-8" }
  data = { id: error.id, message: error.message }
  [error.status, headers, [MultiJson.encode(data)]]
end