Skip to content

Commit

Permalink
Appends the load paths to error message
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Holger Frohloff authored and schneems committed Jul 21, 2016
1 parent 6cce506 commit 42a022b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/sprockets/resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42a022b

Please sign in to comment.