From 80d25f208fb5f6d42318cff9346ef2eb759f493c Mon Sep 17 00:00:00 2001 From: Godwin Date: Tue, 12 Jul 2016 15:29:22 -0700 Subject: [PATCH] Update application_controller.rb --- app/controllers/application_controller.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 34e6080..5cdd448 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -125,7 +125,7 @@ class ApplicationController < LinguaFrancaApplicationController report += " in #{params[:url]}:#{params[:lineNumber]}" end - suppress(Exception) do + begin # log the error logger.info exception.to_s logger.info exception.backtrace.join("\n") @@ -141,6 +141,9 @@ class ApplicationController < LinguaFrancaApplicationController current_user, ] end if Rails.env.preview? || Rails.env.production? + rescue exception2 + logger.info exception2.to_s + logger.info exception2.backtrace.join("\n") end render json: {} end @@ -192,7 +195,7 @@ class ApplicationController < LinguaFrancaApplicationController "An error has occurred in #{Rails.env}", nil, exception.to_s, - exception, + exception.backtrace.join("\n"), request, params, current_user, @@ -395,20 +398,25 @@ class ApplicationController < LinguaFrancaApplicationController end def i18n_exception(str, exception, locale, key) + # log it + logger.info "Missing translation found for: #{key}" + # send and email if this is production - suppress(Exception) do + begin UserMailer.send_mail(:error_report) do [ "A missing translation found in #{Rails.env}", "

A translation for #{key} in #{locale.to_s} was found. The text that was rendered to the user was:

#{str || 'nil'}
", exception.to_s, - exception, + nil, request, params, current_user, ] end if Rails.env.preview? || Rails.env.production? - logger.info "Missing translation found for: #{key}" + rescue exception2 + logger.info exception2.to_s + logger.info exception2.backtrace.join("\n") end end end