lib/deferrable_gratification/primitives.rb
def failure(exception_class_or_message, message_or_nil = nil)
      blank.tap do |d|
        d.fail(
          case exception_class_or_message
          when Exception
            raise ArgumentError, "can't specify both exception and message" if message_or_nil
            exception_class_or_message
          when Class
            exception_class_or_message.new(message_or_nil)
          else
            RuntimeError.new(exception_class_or_message.to_s)
          end)
      end
    end
def failure(exception_class_or_message, message_or_nil = nil)
      blank.tap do |d|
        d.fail(
          case exception_class_or_message
          when Exception
            raise ArgumentError, "can't specify both exception and message" if message_or_nil
            exception_class_or_message
          when Class
            exception_class_or_message.new(message_or_nil)
          else
            RuntimeError.new(exception_class_or_message.to_s)
          end)
      end
    end
Return a Deferrable which immediately fails with an exception.

 @overload failure(message)
   Passes +RuntimeError.new(message)+ to errbacks.
 @overload failure(exception_class)
   Passes +exception_class.new+ to errbacks.
 @overload failure(exception_class, message)
   Passes +exception_class.new(message)+ to errbacks.
 @overload failure(exception)
   Passes +exception+ to errbacks.