aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-07-08 02:10:12 -0700
committerJosé Valim <jose.valim@plataformatec.com.br>2012-07-08 02:10:12 -0700
commit7404cda9f61e41d52ce244d60abbf598684a96c4 (patch)
treef18a3cb9ab270a4a4f2bf3745c83382667d2f14a /actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
parentee20be7c33538e6e9d334ddbd16d427190c7ff00 (diff)
parentbbfd29a65572d03d4faae791a56453edaedadb3d (diff)
downloadrails-7404cda9f61e41d52ce244d60abbf598684a96c4.tar.gz
rails-7404cda9f61e41d52ce244d60abbf598684a96c4.tar.bz2
rails-7404cda9f61e41d52ce244d60abbf598684a96c4.zip
Merge pull request #6696 from schneems/schneems/sextant-routing-error
Show Routes while Debugging RoutingError
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/debug_exceptions.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/debug_exceptions.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
index b903f98761..af3e6b3557 100644
--- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
@@ -1,5 +1,7 @@
require 'action_dispatch/http/request'
require 'action_dispatch/middleware/exception_wrapper'
+require 'action_dispatch/routing/inspector'
+
module ActionDispatch
# This middleware is responsible for logging exceptions and
@@ -7,8 +9,9 @@ module ActionDispatch
class DebugExceptions
RESCUES_TEMPLATE_PATH = File.join(File.dirname(__FILE__), 'templates')
- def initialize(app)
- @app = app
+ def initialize(app, routes_app = nil)
+ @app = app
+ @routes_app = routes_app
end
def call(env)
@@ -39,7 +42,8 @@ module ActionDispatch
:exception => wrapper.exception,
:application_trace => wrapper.application_trace,
:framework_trace => wrapper.framework_trace,
- :full_trace => wrapper.full_trace
+ :full_trace => wrapper.full_trace,
+ :routes => formatted_routes(exception)
)
file = "rescues/#{wrapper.rescue_template}"
@@ -78,5 +82,14 @@ module ActionDispatch
def stderr_logger
@stderr_logger ||= ActiveSupport::Logger.new($stderr)
end
+
+ private
+ def formatted_routes(exception)
+ return false unless @routes_app.respond_to?(:routes)
+ if exception.is_a?(ActionController::RoutingError) || exception.is_a?(ActionView::Template::Error)
+ inspector = ActionDispatch::Routing::RouteInspector.new
+ inspector.format(@routes_app.routes.routes).join("\n")
+ end
+ end
end
end