Class: ErrorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/errors_controller.rb

Instance Attribute Summary

Attributes included from PagesCore::Authentication

#current_user

Instance Method Summary collapse

Methods included from PagesCore::PoliciesHelper

#policy, #verify_policy, #verify_policy_with_proc

Methods included from PagesCore::ProcessTitler

inc_number_of_requests, original_title

Methods included from PagesCore::ErrorRenderer

#render_error

Methods included from PagesCore::Authentication

#authenticate!, #deauthenticate!, #logged_in?

Instance Method Details

#forbiddenObject


15
16
17
# File 'app/controllers/errors_controller.rb', line 15

def forbidden
  render_error 403
end

#internal_errorObject


31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/errors_controller.rb', line 31

def internal_error
  exception = request.env["action_dispatch.exception"]
  if !exception
    render_error 500
  elsif exception.is_a?(PagesCore::NotAuthorized)
    render_error 403
  else
    @report = encrypt_report(error_report(request, exception))
    wrapper = ActionDispatch::ExceptionWrapper.new(nil, exception)
    render_error wrapper.status_code
  end
end

#not_foundObject


19
20
21
# File 'app/controllers/errors_controller.rb', line 19

def not_found
  render_error 404
end

#reportObject


4
5
6
7
8
9
# File 'app/controllers/errors_controller.rb', line 4

def report
  report = decrypt_report(params[:error_report])
  report[:user] = User.find_by(id: report[:user_id]) if report.key?(:user_id)

  deliver_error_report(report, params[:email], params[:description])
end

#showObject


11
12
13
# File 'app/controllers/errors_controller.rb', line 11

def show
  render_error params[:id].to_i
end

#unacceptableObject


23
24
25
# File 'app/controllers/errors_controller.rb', line 23

def unacceptable
  render_error 422
end

#unauthorizedObject


27
28
29
# File 'app/controllers/errors_controller.rb', line 27

def unauthorized
  render_error 401
end