You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. require 'action_dispatch/middleware/exception_wrapper'
  2. require 'action_dispatch/routing/inspector'
  3. require 'action_view'
  4. module ActionDispatch
  5. module Middleware
  6. # THIS IS A HACK TO unwrap TagWrapError when detected!
  7. # TagWrapError contains a 'tag' for SemanticLogger and the cause itself
  8. class DebugExceptions
  9. private
  10. def render_exception(request, exception, wrapper)
  11. ## PVINCENT's ADDITION for TagWrapError
  12. log_error(request, wrapper)
  13. if exception.is_a?(Semantic::TagWrapError)
  14. backtrace_cleaner = request.get_header('action_dispatch.backtrace_cleaner')
  15. wrapper = ExceptionWrapper.new(backtrace_cleaner, exception.error)
  16. end
  17. ## HERE it was commented off
  18. # log_error(request, wrapper)
  19. ## END OF ADDITION
  20. raise exception unless request.get_header('action_dispatch.show_detailed_exceptions')
  21. begin
  22. content_type = request.formats.first
  23. rescue ActionDispatch::Http::MimeNegotiation::InvalidType
  24. content_type = Mime[:text]
  25. end
  26. if api_request?(content_type)
  27. render_for_api_request(content_type, wrapper)
  28. else
  29. render_for_browser_request(request, wrapper)
  30. end
  31. end
  32. end
  33. end
  34. end