Module: RocketPants::ErrorHandling::ClassMethods
- Defined in:
- lib/rocket_pants/controller/error_handling.rb
Instance Method Summary collapse
-
#map_error!(from, to = nil, &blk) ⇒ Object
Declares that a given error class (e.g. ActiveRecord::RecordNotFound) should map to a second value - either an Exception class Or, more usefully, a callable object.
Instance Method Details
#map_error!(from, to = nil, &blk) ⇒ Object
Declares that a given error class (e.g. ActiveRecord::RecordNotFound) should map to a second value - either an Exception class Or, more usefully, a callable object.
21 22 23 24 25 26 |
# File 'lib/rocket_pants/controller/error_handling.rb', line 21 def map_error!(from, to = nil, &blk) to = (to || blk) raise ArgumentError, "Either an option must be provided or a block given." unless to error_mapping[from] = (to || blk) rescue_from from, :with => :render_error end |