Why doesn't this work?? I expect the rescue block to be executed if an ActionView::TemplateError
is raised. But that isn't happening for some reason...
The following is a controller action in a rails 4 app.
def categorized
#ActionView::TemplateError raising code
rescue ActionView::TemplateError
binding.pry
end
how about if move exception in application_controller.rb:
rescue_from ActionView::TemplateError do | exception |
binding.pry
end
Try with
rescue => e
bindig.pry
After you that you can check error class with e.class, to make sure you are catching good exception.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.