A
A
Alexander N++2015-11-18 15:28:29
Ruby on Rails
Alexander N++, 2015-11-18 15:28:29

How to display 500 errors in rails?

Everything worked fine and then at one point the application crashes. I want to find out why the application crashes, but there is not enough knowledge in rails (((
In the main controller, errors are processed like this

unless Rails.application.config.consider_all_requests_local
    rescue_from Exception, with: lambda { |exception| render_error 500, exception }
    rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception }
  end

  def render_error(status, exception)
    @is_in_error = true
    respond_to do |format|
     format.html { render template: "errors/error_#{status}", layout: 'layouts/application', status: status , exception: exception }
     format.all { render nothing: true, status: status }
    end
  end

There was no view for 500 errors, I created an empty view. I thought I would see a long-awaited error why any page 500 error in the logs, what a naive I was, the logs became empty
Then I finished the angiology view with 404
But since I don’t understand HAML
%p.wow='УПС... 500'
.text
  %p='Xьюстон у нас потери'
  %p.support
    Служба поддержки - 
    =link_to support_url, support_path , exception.message

How to output exception.message correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2015-11-18
@vsuhachev

If the goal is to understand what the error is, then look at the logs (log/production.log inside the application directory)
And for this, all sorts of newrelic, airbrake, rollbar, etc are often used

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question