Module: WingedCouch::Exceptions

Defined in:
lib/winged_couch/exceptions.rb,
lib/winged_couch/exceptions/handler.rb,
lib/winged_couch/exceptions/handlers/base.rb

Defined Under Namespace

Modules: Handlers Classes: Handler

Constant Summary collapse

Base =
Class.new(StandardError)
NoDatabase =

Database-specific exceptions

error { |db_name| %Q{Database "#{db_name}" is missing} }
DatabaseAlreadyExist =
error { |db_name| %Q{Database "#{name}" already exist} }
ReservedDatabase =
error { |db_name| %Q{Database "#{db_name}" is internal, you can't remove it.} }
DocumentMissing =

Document-specific exceptions

error { |message| message }
InvalidDocument =
error { |message| message }
NoDesignDocument =

DesignDocument-specific exceptions

error { |db_name| %Q{Can't find design document in database "#{db_name}"} }
UnsupportedType =

Model-specific exceptions

error { |klass1, klass2| "Unsupported class #{klass1} used for type-casting attribute in model #{klass2}" }
UnknownView =

View-specific exceptions

error { |view_name| %Q{Unknown view "#{view_name}"} }
ViewsMissing =
error { |klass| %Q{Can't find views for #{klass}} }

Class Method Summary collapse

Class Method Details

.error(&block) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/winged_couch/exceptions.rb', line 12

def error(&block)
  Class.new(Base).tap do |klass|
    class << klass
      attr_accessor :blk

      def raise(*args)
        message = blk.call(*args)
        Kernel.raise self, message
      end
    end
    klass.blk = block
  end
end