Browse Source

bootstrap, however on error no toto1 session

main
pvincent 2 months ago
parent
commit
3e5817e99e
  1. 7
      config/initializers/semantic_logger.rb
  2. 50
      lib/monkey_patches/action_dispatch/middleware/debug_exceptions.rb

7
config/initializers/semantic_logger.rb

@ -10,7 +10,14 @@ end
Rails.configuration.after_initialize do Rails.configuration.after_initialize do
Semantic::InstrumentationManager.clear Semantic::InstrumentationManager.clear
bootstrap = [{ kind: :restored, constant: 'ACTION_VIEW', type: :boolean, old_value: false, new_value: true },
{ kind: :restored, constant: 'ACTION_CONTROLLER', type: :boolean, old_value: false, new_value: true }]
im ||= Semantic::InstrumentationManager.new
im.process(bootstrap)
ActiveSupport::Notifications.subscribe('rolling.live_constant') do |event| ActiveSupport::Notifications.subscribe('rolling.live_constant') do |event|
puts event.payload[:changes].inspect
im.process(event.payload[:changes]) im.process(event.payload[:changes])
rescue StandardError => e rescue StandardError => e
puts e puts e

50
lib/monkey_patches/action_dispatch/middleware/debug_exceptions.rb

@ -3,33 +3,35 @@ require 'action_dispatch/routing/inspector'
require 'action_view' require 'action_view'
module ActionDispatch module ActionDispatch
# THIS IS A HACK TO unwrap TagWrapError when detected!
# TagWrapError contains a 'tag' for SemanticLogger and the cause itself
class DebugExceptions
private
module Middleware
# THIS IS A HACK TO unwrap TagWrapError when detected!
# TagWrapError contains a 'tag' for SemanticLogger and the cause itself
class DebugExceptions
private
def render_exception(request, exception, wrapper)
## PVINCENT's ADDITION for TagWrapError
log_error(request, wrapper)
if exception.is_a?(Semantic::TagWrapError)
backtrace_cleaner = request.get_header('action_dispatch.backtrace_cleaner')
wrapper = ExceptionWrapper.new(backtrace_cleaner, exception.error)
end
## HERE it was commented off
# log_error(request, wrapper)
## END OF ADDITION
def render_exception(request, exception, wrapper)
## PVINCENT's ADDITION for TagWrapError
log_error(request, wrapper)
if exception.is_a?(Semantic::TagWrapError)
backtrace_cleaner = request.get_header('action_dispatch.backtrace_cleaner')
wrapper = ExceptionWrapper.new(backtrace_cleaner, exception.error)
end
## HERE it was commented off
# log_error(request, wrapper)
## END OF ADDITION
raise exception unless request.get_header('action_dispatch.show_detailed_exceptions')
raise exception unless request.get_header('action_dispatch.show_detailed_exceptions')
begin
content_type = request.formats.first
rescue ActionDispatch::Http::MimeNegotiation::InvalidType
content_type = Mime[:text]
end
if api_request?(content_type)
render_for_api_request(content_type, wrapper)
else
render_for_browser_request(request, wrapper)
begin
content_type = request.formats.first
rescue ActionDispatch::Http::MimeNegotiation::InvalidType
content_type = Mime[:text]
end
if api_request?(content_type)
render_for_api_request(content_type, wrapper)
else
render_for_browser_request(request, wrapper)
end
end end
end end
end end

Loading…
Cancel
Save