Skip to content

Commit

Permalink
Merge pull request #313 from 5minpause/5minpause-load-path-error-mess…
Browse files Browse the repository at this point in the history
…ages

Appends the load paths to error message
  • Loading branch information
schneems committed Jun 22, 2016
2 parents 33a74d2 + ffef39f commit 2702b33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit 2702b33

Please sign in to comment.