Update app/controllers/application_controller.rb

add check_errors method