From 3f4139f6133e44cfcda58c64fdd6d13181a43517 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 1 Jul 2015 17:01:02 +0300 Subject: [PATCH] Rescue internal errors inside the app, not through mod_epp #2694 --- app/controllers/epp_controller.rb | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb index 16090a885..6a982d9be 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -10,15 +10,29 @@ class EppController < ApplicationController before_action :update_epp_session helper_method :current_user - rescue_from CanCan::AccessDenied do |_exception| + rescue_from StandardError do |e| @errors ||= [] - if @errors.blank? - @errors = [{ - msg: t('errors.messages.epp_authorization_error'), - code: '2201' - }] + if e.class == CanCan::AccessDenied + if @errors.blank? + @errors = [{ + msg: t('errors.messages.epp_authorization_error'), + code: '2201' + }] + end + else + if @errors.blank? + @errors = [{ + msg: 'Internal error.', + code: '2400' + }] + end + + logger.error e.message + logger.error e.backtrace.join("\n") + # TODO: NOITFY AIRBRAKE / ERRBIT HERE end + render_epp_response '/epp/error' end