Guest User

Untitled

a guest
May 27th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. def exceptions_to_treat_as_404
  2. exceptions = [ActiveRecord::RecordNotFound,
  3. ActionController::UnknownController,
  4. ActionController::UnknownAction]
  5. exceptions << ActionController::RoutingError if ActionController.const_defined?(:RoutingError)
  6. exceptions
  7. end
  8.  
  9. def rescue_action_in_public(exception)
  10. case exception
  11. when *self.class.exceptions_to_treat_as_404
  12. render_404
  13.  
  14. else
  15. # render_500
  16. # dont render_500, do it in application.rb
  17.  
  18. deliverer = self.class.exception_data
  19. data = case deliverer
  20. when nil then {}
  21. when Symbol then send(deliverer)
  22. when Proc then deliverer.call(self)
  23. end
  24.  
  25. ExceptionNotifier.deliver_exception_notification(exception, self,
  26. request, data)
  27. end
  28. end
Add Comment
Please, Sign In to add comment