Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 1660

Show
Ignore:
Timestamp:
07/04/05 09:54:30 (3 years ago)
Author:
david
Message:

Improved the whiny nil #1600 [Nicholas Seckar]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/whiny_nil.rb

    r1507 r1660  
    2020   
    2121  def id 
    22     raise "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id" 
     22    raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller 
    2323  end 
    2424 
     
    2626    def method_missing(method, *args, &block) 
    2727      if @@method_class_map.include?(method) 
    28         raise_nil_warning_for @@method_class_map[method] 
     28        raise_nil_warning_for @@method_class_map[method], caller 
    2929      else 
    3030        super 
     
    3232    end 
    3333 
    34     def raise_nil_warning_for(klass
    35       raise NoMethodError, NIL_WARNING_MESSAGE % klass 
     34    def raise_nil_warning_for(klass, with_caller = nil
     35      raise NoMethodError, NIL_WARNING_MESSAGE % klass, with_caller || caller 
    3636    end 
    3737