class Sinatra::Base

def error_block!(*keys)

Find an custom error block for the key(s) specified.
def error_block!(*keys)
  keys.each do |key|
    base = self.class
    while base.respond_to?(:errors)
      if block = base.errors[key]
        # found a handler, eval and return result
        return instance_eval(&block)
      else
        base = base.superclass
      end
    end
  end
  raise boom if settings.show_exceptions? and keys == Exception
  nil
end