Exception: Recliner::CouchDBError

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

Overview

Encapsulates a critical error from CouchDB. Raised by the Recliner base methods when an error response is returned. Use the error and reason methods to retrieve the specific error.

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ CouchDBError

Returns a new instance of CouchDBError.



6
7
8
# File 'lib/recliner/exceptions.rb', line 6

def initialize(response=nil)
  @error = JSON.parse(response) if response
end

Instance Method Details

#errorObject



10
11
12
# File 'lib/recliner/exceptions.rb', line 10

def error
  @error['error'] if @error
end

#messageObject



18
19
20
# File 'lib/recliner/exceptions.rb', line 18

def message
  "CouchDB error: #{error} (#{reason})"
end

#reasonObject



14
15
16
# File 'lib/recliner/exceptions.rb', line 14

def reason
  @error['reason'] if @error
end

#to_sObject



22
23
24
# File 'lib/recliner/exceptions.rb', line 22

def to_s
  message
end