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

Add more descriptive error to file loading #433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/que/command_line_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ def parse(
end

args.each do |file|
begin
require file
rescue LoadError => e
output.puts "Could not load file '#{file}': #{e}"
return 1
end
require File.expand_path(file)
end

Que.logger ||= Logger.new(STDOUT)
Expand Down
7 changes: 2 additions & 5 deletions spec/que/command_line_interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def write_file
it "should infer the default require file if it exists" do
filename = write_file

assert_successful_invocation "", default_require_file: "./#{filename}.rb"
assert_successful_invocation "", default_require_file: "#{filename}.rb"

assert_equal(
{filename => true},
Expand Down Expand Up @@ -161,10 +161,7 @@ def write_file

it "should raise an error if any of the files don't exist" do
name = write_file
code = execute "./#{name} ./nonexistent_file"
assert_equal 1, code

assert_equal ["Could not load file './nonexistent_file': cannot load such file -- ./nonexistent_file"], output.messages
assert_raises(LoadError) { execute "#{name} ./nonexistent_file" }

assert_equal(
{name => true},
Expand Down