From 42a022b17c2641cca3218431cacfdd9795de4af1 Mon Sep 17 00:00:00 2001 From: Holger Frohloff Date: Thu, 16 Jun 2016 10:37:53 +0200 Subject: [PATCH] Appends the load paths to error message When `resolve!` raises an error, it would not display the paths that were used to look up the assets. If we raise this error we can be even more helpful and display the `config[:path]` as well. This makes it easier for users to debug their asset paths. References #252 --- lib/sprockets/resolve.rb | 1 + test/test_server.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sprockets/resolve.rb b/lib/sprockets/resolve.rb index e240471a9..5026379eb 100644 --- a/lib/sprockets/resolve.rb +++ b/lib/sprockets/resolve.rb @@ -60,6 +60,7 @@ def resolve!(path, options = {}) end message << " with type '#{options[:accept]}'" if options[:accept] + message << "\nLooked up these paths: #{config[:paths]}" raise FileNotFound, message end diff --git a/test/test_server.rb b/test/test_server.rb index 6fce22eb0..1b9bc1594 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -283,7 +283,7 @@ def app test "re-throw JS exceptions in the browser" do get "/assets/missing_require.js" assert_equal 200, last_response.status - assert_equal "throw Error(\"Sprockets::FileNotFound: couldn't find file 'notfound' with type 'application/javascript'\\n (in #{fixture_path("server/vendor/javascripts/missing_require.js")}:1)\")", last_response.body + assert_equal "throw Error(\"Sprockets::FileNotFound: couldn't find file 'notfound' with type 'application/javascript'\\nLooked up these paths: #{@env.paths}\\n (in #{fixture_path("server/vendor/javascripts/missing_require.js")}:1)\")", last_response.body end test "display CSS exceptions in the browser" do