Sha256: 0deb6da51e82ec61231109f9b3b77689ad99eaac718441af9f1c658f8ca08026

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

module Recliner
  # 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.
  class CouchDBError < StandardError
    def initialize(response=nil)
      @error = JSON.parse(response) if response
    end
    
    def error
      @error['error'] if @error
    end
    
    def reason
      @error['reason'] if @error
    end
    
    def message
      "CouchDB error: #{error} (#{reason})"
    end
    
    def to_s
      message
    end
  end
 
  # Raised when a document cannot be found in the database.
  class DocumentNotFound < StandardError; end
  
  # Raised when a document was not saved (e.g. when a callback returns false).
  class DocumentNotSaved < StandardError; end
  
  # Raised when an incorrect revision is given when updating a document.
  class StaleRevisionError < DocumentNotSaved; end

#   class AssociationTypeMismatch < StandardError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recliner-0.0.1 lib/recliner/exceptions.rb