Commit be4138af75b2a80ceb7d444c573fc35c644d9c63
1 parent
96b2959f
Exists in
master
and in
4 other branches
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,19 +9,28 @@ class ApplicationController < ActionController::Base | ||
| 9 | helper_method :abilities, :can? | 9 | helper_method :abilities, :can? |
| 10 | 10 | ||
| 11 | rescue_from Gitlab::Gitolite::AccessDenied do |exception| | 11 | rescue_from Gitlab::Gitolite::AccessDenied do |exception| |
| 12 | + log_exception(exception) | ||
| 12 | render "errors/gitolite", layout: "errors", status: 500 | 13 | render "errors/gitolite", layout: "errors", status: 500 |
| 13 | end | 14 | end |
| 14 | 15 | ||
| 15 | rescue_from Encoding::CompatibilityError do |exception| | 16 | rescue_from Encoding::CompatibilityError do |exception| |
| 17 | + log_exception(exception) | ||
| 16 | render "errors/encoding", layout: "errors", status: 500 | 18 | render "errors/encoding", layout: "errors", status: 500 |
| 17 | end | 19 | end |
| 18 | 20 | ||
| 19 | rescue_from ActiveRecord::RecordNotFound do |exception| | 21 | rescue_from ActiveRecord::RecordNotFound do |exception| |
| 22 | + log_exception(exception) | ||
| 20 | render "errors/not_found", layout: "errors", status: 404 | 23 | render "errors/not_found", layout: "errors", status: 404 |
| 21 | end | 24 | end |
| 22 | 25 | ||
| 23 | protected | 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 | def reject_blocked! | 34 | def reject_blocked! |
| 26 | if current_user && current_user.blocked | 35 | if current_user && current_user.blocked |
| 27 | sign_out current_user | 36 | sign_out current_user |