Reputation: 17532
This code block here throws a warning message in Rails console -- warning: else without rescue is useless
def handle_exceptions(e)
case e
when ActionController::UnknownAction, ActiveRecord::RecordNotFound, ActionController::RoutingError
not_found
else
internal_error(e)
end
end
Any clue why?
Upvotes: 3
Views: 4149
Reputation: 18845
i think that this error is not from the source code you posted but from where it is called.
i can prove it with this implementation, which also uses 1.9.2-p290:
module ActionController
class UnknownAction; end
class RoutingError; end
end
module ActiveRecord
class RecordNotFound; end
end
class Test
def test_exception
raise "error"
rescue
handle_exceptions($!)
end
def test_failing
else puts "invalid"
end
end
def not_found
puts "not found"
end
def internal_error(e)
puts e
end
def handle_exceptions(e)
case e
when ActionController::UnknownAction, ActiveRecord::RecordNotFound, ActionController::RoutingError
not_found
else
internal_error(e)
end
end
end
Test.new.test_exception
Test.new.test_failing
Upvotes: 4