module CouchObject module Errors # # Is raised when trying to load a view that doesn't exist on # the couchDB server # class MissingView < StandardError def message "The view doesn't exist on the server." end alias_method :to_s, :message end ##### # # ERRORS for the Persistable module # ##### # # Is raised when a method that interacts with the # document store is called and the location variable # has not been set # class NoDatabaseLocationSet < StandardError def message "Unless the document has previously been saved you need to " + \ "supply the full URI to the CouchDB server where the document " + \ "is to be saved." end alias_method :to_s, :message end # # Is raised when trying to compare two object of which # none has been saved. # class CantCompareSize < StandardError def message "Can't compare the size of two objects unless at least one of " + \ "them has been saved and both have timestamps." end alias_method :to_s, :message end # # Is raised if a has_many relationship is poorly defined # class HasManyAssociationError < StandardError def message "The has_many relationship hasn't been correctly defined. It should look something like: has_many :fruits. Make sure to also include a belongs_to relationship in the related classes that reference back to the has_many relationship. For example like this: belongs_to :fruit_basket, :as => :fruits" end alias_method :to_s, :message end # # Is raised if a belongs_to relationship is poorly defined # class BelongsToAssociationError < StandardError def message "The belongs_to relationship hasn't been properly defined. There are two required parameters: the name of the relation and the name of the corresponding has_many relation in the related class. Example: belongs_to :fruit_basket, :as => :fruits would be correct if the related class has it's relation defined as has_many :fruits" end alias_method :to_s, :message end # # Is raised if a has_one relationship is poorly defined # class HasOneAssociationError < StandardError def message "The has_one relationship hasn't been correctly defined. It should look something like: has_one :sword. Make sure to also include a belongs_to relationship in the related classes that reference back to the has_one relationship. For example like this: belongs_to :master, :as => :sword" end alias_method :to_s, :message end # # This error is raised when trying to load a document that doesn't # exist on the server # class DocumentNotFound < StandardError end # # This error is raised when trying to save or updating # a document fails # class DatabaseSaveFailed < StandardError end # # This error is raised when trying to load a view # but CouchDB screwes it up and returns a MapProcessError # class MapProcessError < StandardError def message "CouchDB screwed it up somehow. There might be something wrong with your view as well." end alias_method :to_s, :message end # # Is raised when one the CouchDB returns an error which isn't covered # by one of the functions above # class CouchDBError < StandardError end end end