diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 31e9aca..5776c10 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,8 +27,10 @@ def log_request_result # or attempt to render a generic error page if no specific error page exists unless Rails.application.config.consider_all_requests_local rescue_from StandardError do |e| - # Instrument ActiveSupport::Notifications for internal errors: - ActiveSupport::Notifications.instrument('internal_error.application', exception: e) + # Instrument ActiveSupport::Notifications for internal errors but only for non-404 errors: + unless e.is_a?(ActionController::RoutingError) || e.is_a?(ActionView::MissingTemplate) + ActiveSupport::Notifications.instrument('internal_error.application', exception: e) + end # Trigger the appropriate error handling method based on the exception case e.class when ActionController::RoutingError, ActionView::MissingTemplate @@ -104,7 +106,7 @@ def detailed_request_log(duration) body: request.body.gets&.gsub("\n", '\n'), method: request.method, status: response.status, - message: Rack::Utils::HTTP_STATUS_CODES[response.status] + message: response.message || Rack::Utils::HTTP_STATUS_CODES[response.status] } case response.status