I would like to send e-mail when having an exception in my application and render the regular 500 page. I could not find how to perform the 500 page render:
class ApplicationController < ActionController::Base
  rescue_from StandardError do
     send_email_of_error
     # what goes here? 
  end
  ...
end
                Raising the exception again will likely to what you want:
rescue_from StandardError do |exception|
  send_email_of_error
  raise exception
end
You could also call render to render your own page, the docs have an example doing this.
But why reinvent the wheel? The exception notifier gem already does this and is customizable and tested.
This is an approach that maybe fits your needs:
class ApplicationController < ActionController::Base
  rescue_from Exception, :with => :render_500
  def render_500(exception)
    @exception = exception
    render :template => "shared/500.html", :status => 500
  end
end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With