From 3bd643e182e681a047768583b0c2eb2b34f45a2c Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 31 Jul 2014 08:51:47 +0200 Subject: filter out 404 error traces They add very little value and clutter the production logs when bots scan. --- config/initializers/exception_filter.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 config/initializers/exception_filter.rb diff --git a/config/initializers/exception_filter.rb b/config/initializers/exception_filter.rb new file mode 100644 index 0000000..18c74d9 --- /dev/null +++ b/config/initializers/exception_filter.rb @@ -0,0 +1,10 @@ +class ActionDispatch::DebugExceptions + def log_error_with_exception_filter(env, wrapper) + if wrapper.exception.is_a? ActionController::RoutingError + return + else + log_error_without_exception_filter env, wrapper + end + end + alias_method_chain :log_error, :exception_filter +end -- cgit v1.2.3 From 8529177baeb08b96f613148ebef0bf5861d897d1 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 31 Jul 2014 08:53:08 +0200 Subject: respond with 404 and 500 when rendering custom error pages includes test --- app/controllers/errors_controller.rb | 2 ++ test/functional/errors_controller_test.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/functional/errors_controller_test.rb diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 6c659e6..d869ab5 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -2,9 +2,11 @@ class ErrorsController < ApplicationController # 404 def not_found + render status: 404 end # 500 def server_error + render status: 500 end end diff --git a/test/functional/errors_controller_test.rb b/test/functional/errors_controller_test.rb new file mode 100644 index 0000000..e6d2367 --- /dev/null +++ b/test/functional/errors_controller_test.rb @@ -0,0 +1,14 @@ +class ErrorsControllerTest < ActionController::TestCase + + def test_not_found_resonds_with_404 + get 'not_found' + assert_response 404 + assert_template 'errors/not_found' + end + + def test_server_error_resonds_with_500 + get 'server_error' + assert_response 500 + assert_template 'errors/server_error' + end +end -- cgit v1.2.3 From 546aaa9f39b40a3f11670c805bb71e4ace7d0cc7 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 31 Jul 2014 09:42:37 +0200 Subject: update debugger to work with latest ruby --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 38a8793..0a269f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,12 +101,12 @@ GEM nokogiri (~> 1.5) rails (>= 3, < 5) daemons (1.1.9) - debugger (1.6.6) + debugger (1.6.8) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.3.2) + debugger-ruby_core_source (~> 1.3.5) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.3.2) + debugger-ruby_core_source (1.3.5) diff-lcs (1.2.5) erubis (2.7.0) eventmachine (1.0.3) -- cgit v1.2.3