Module: Analysand::Errors

Included in:
Database, Instance
Defined in:
lib/analysand/errors.rb

Overview

Private: Methods to generate exceptions.

Instance Method Summary collapse

Instance Method Details

#bulk_ex(klass, response) ⇒ Object

Like #ex, but customized for bulk operations. (CouchDB’s bulk_docs can return 2xx even on failure; you need to inspect the response body to figure out what happened.)

klass - the exception class response - the response object that caused the error



20
21
22
23
24
# File 'lib/analysand/errors.rb', line 20

def bulk_ex(klass, response)
  klass.new("Bulk operation failed (some records reported failure)").tap do |ex|
    ex.response = response
  end
end

#ex(klass, response) ⇒ Object

Instantiates an exception and fills in a response.

klass - the exception class response - the response object that caused the error



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

def ex(klass, response)
  klass.new("Expected response to have code 2xx, got #{response.code} instead").tap do |ex|
    ex.response = response
  end
end