Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appends the load paths to error message #313

Merged
merged 2 commits into from Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/sprockets/resolve.rb
Expand Up @@ -60,6 +60,7 @@ def resolve!(path, options = {})
end

message << " with type '#{options[:accept]}'" if options[:accept]
message << "\nChecked in these paths: \n #{ config[:paths].join("\n ") }"

raise FileNotFound, message
end
Expand Down
12 changes: 12 additions & 0 deletions test/test_resolve.rb
Expand Up @@ -251,6 +251,18 @@ def setup
@env.each_logical_path("application.js", /gallery\.css/).to_a
end

test "adds paths to exceptions" do
random_path = SecureRandom.hex
@env.append_path(random_path)

error = assert_raises(Sprockets::FileNotFound) do
uri, _ = @env.resolve!("thisfiledoesnotexistandshouldraiseerrors", {})
uri
end

assert_match /#{ random_path }/, error.message
end

def resolve(path, options = {})
uri, _ = @env.resolve(path, options.merge(compat: false))
uri
Expand Down
3 changes: 2 additions & 1 deletion test/test_server.rb
Expand Up @@ -283,7 +283,8 @@ 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_match /Sprockets::FileNotFound: couldn't find file 'notfound' with type 'application\/javascript'/, last_response.body
assert_match /(in #{fixture_path("server/vendor/javascripts/missing_require.js")}:1)/, last_response.body
end

test "display CSS exceptions in the browser" do
Expand Down