def rescue_action_locally(request, exception)
      # TODO this should probably move to the controller, that is, have
      # http error codes map directly to controller actions, then let
      # controller handle different exception classes however it wants
      rescue_actions = Hash.new('diagnostics')
      rescue_actions.update({
        'ActionView::MissingTemplate'         => 'missing_template',
        'ActionController::RoutingError'      => 'routing_error',
        'AbstractController::ActionNotFound'  => 'unknown_action',
        'ActionView::Template::Error'         => 'template_error'
      })

      error_params = {
        :request => request, :exception => exception,
        :application_trace => application_trace(exception),
        :framework_trace => framework_trace(exception),
        :full_trace => full_trace(exception)
      }
      request.env['goalie.error_params'] = error_params
      action = rescue_actions[exception.class.name]
      response = LocalErrorsController.action(action).call(request.env).last
      render(status_code(exception), response.body)
    end
def rescue_action_locally(request, exception)
      # TODO this should probably move to the controller, that is, have
      # http error codes map directly to controller actions, then let
      # controller handle different exception classes however it wants
      rescue_actions = Hash.new('diagnostics')
      rescue_actions.update({
        'ActionView::MissingTemplate'         => 'missing_template',
        'ActionController::RoutingError'      => 'routing_error',
        'AbstractController::ActionNotFound'  => 'unknown_action',
        'ActionView::Template::Error'         => 'template_error'
      })

      error_params = {
        :request => request, :exception => exception,
        :application_trace => application_trace(exception),
        :framework_trace => framework_trace(exception),
        :full_trace => full_trace(exception)
      }
      request.env['goalie.error_params'] = error_params
      action = rescue_actions[exception.class.name]
      response = LocalErrorsController.action(action).call(request.env).last
      render(status_code(exception), response.body)
    end
Render detailed diagnostics for unhandled exceptions rescued from
 a controller action.