Sha256: 4bee153ad1e5c6c2b157391b32e3daa3d4052628546ee8ac6718c0475fa933e6
Contents?: true
Size: 1.38 KB
Versions: 8
Compression:
Stored size: 1.38 KB
Contents
module NdrError module Middleware # Middleware for logging exceptions, can be used as exception_app for Rails. class PublicExceptions < ::ActionDispatch::PublicExceptions def call(env) rescuing_everything do request = ActionDispatch::Request.new(env) exception = env['action_dispatch.exception'] # "falsey" callback return value allows logging to be skipped log_exception(request, exception) if run_exception_callback(request, exception) end super # Invoke the PublicExceptions behaviour end private def log_exception(request, exception) parameters = NdrError.log_parameters.call(request) _fingerprint, _log = NdrError.log(exception, parameters, request) end def run_exception_callback(request, exception) NdrError.exception_app_callback.call(request, exception) end # Unhandled exceptions with logging could terminate the web server! def rescuing_everything yield rescue Exception => exception # rubocop:disable Lint/RescueException # "Log the exception caused by logging an exception..." Rails.logger.warn <<-MSG.strip_heredoc NdrError failed to log an exception! logging error class: #{exception.class} logging error message: #{exception.message} MSG end end end end
Version data entries
8 entries across 8 versions & 1 rubygems