Commit be4138af75b2a80ceb7d444c573fc35c644d9c63

Authored by Riyad Preukschas
1 parent 96b2959f

Log caught exceptions

Showing 1 changed file with 9 additions and 0 deletions   Show diff stats
app/controllers/application_controller.rb
... ... @@ -9,19 +9,28 @@ class ApplicationController < ActionController::Base
9 9 helper_method :abilities, :can?
10 10  
11 11 rescue_from Gitlab::Gitolite::AccessDenied do |exception|
  12 + log_exception(exception)
12 13 render "errors/gitolite", layout: "errors", status: 500
13 14 end
14 15  
15 16 rescue_from Encoding::CompatibilityError do |exception|
  17 + log_exception(exception)
16 18 render "errors/encoding", layout: "errors", status: 500
17 19 end
18 20  
19 21 rescue_from ActiveRecord::RecordNotFound do |exception|
  22 + log_exception(exception)
20 23 render "errors/not_found", layout: "errors", status: 404
21 24 end
22 25  
23 26 protected
24 27  
  28 + def log_exception(exception)
  29 + application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace
  30 + application_trace.map!{ |t| " #{t}\n" }
  31 + logger.error "\n#{exception.class.name} (#{exception.message}):\n#{application_trace.join}"
  32 + end
  33 +
25 34 def reject_blocked!
26 35 if current_user && current_user.blocked
27 36 sign_out current_user
... ...