#{params[:location]}
"
if params[:location] == params[:url]
report += " on line #{params[:lineNumber]}
"
else
report += " in #{params[:url]}:#{params[:lineNumber]}
"
end
suppress(Exception) do
# log the error
logger.info exception.to_s
logger.info exception.backtrace.join("\n")
UserMailer.send_mail(:error_report) do
[
"A JavaScript error has occurred",
report,
params[:message],
nil,
request,
params,
current_user,
]
end if Rails.env.preview? || Rails.env.production?
end
render json: {}
end
rescue_from ActiveRecord::RecordNotFound do |exception|
do_404
end
rescue_from ActiveRecord::PremissionDenied do |exception|
do_403
end
rescue_from AbstractController::ActionNotFound do |exception|
@banner_image = 'grafitti.jpg'
if current_user
@page_title = nil#'page_titles.Please_Login'
do_403 'not_a_translator'
#return
else
@page_title = 'page_titles.403.Please_Login'
do_403 'translator_login'
end
end
def locale_not_enabled!(locale = nil)
locale_not_available!(locale)
end
def locale_not_available!(locale = nil)
# set_default_locale
params[:_original_action] = params[:action]
params[:action] = 'error-locale-not-available'
@page_title = 'page_titles.404.Locale_Not_Available'
@main_title_vars = { vars: { language: view_context.language(locale) } }
@main_title = 'error.locale_not_available.title'
render 'application/locale_not_available', status: 404
end
rescue_from StandardError do |exception|
# log the error
logger.info exception.to_s
logger.info exception.backtrace.join("\n")
# send and email if this is production
suppress(Exception) do
UserMailer.send_mail(:error_report) do
[
"An error has occurred in #{Rails.env}",
nil,
exception.to_s,
exception,
request,
params,
current_user,
]
end if Rails.env.preview? || Rails.env.production?
end
# raise the error if we are in development so that we can debug it
raise exception if Rails.env.development?
# show the error page
error_500 exception
end
def generate_confirmation(user, url, expiry = nil)
if user.is_a? String
user = User.find_by_email(user)
# if the user doesn't exist, just show them a 403
do_403 unless user.present?
end
expiry ||= (Time.now + 12.hours)
session[:confirm_uid] = user.id
UserMailer.send_mail :email_confirmation do
EmailConfirmation.create(user_id: user.id, expiry: expiry, url: url)
end
end
def user_settings
@main_title = @page_title = 'page_titles.user_settings.Your_Account'
end
def contact
@main_title = @page_title = 'page_titles.contact.Contact_Us'
end
def contact_send
email_list = ['Godwin 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, request, params, current_user, ] end if Rails.env.preview? || Rails.env.production? logger.info "Missing translation found for: #{key}" end end end