Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Pass Errno::ENOENT message to local exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ka8725 authored and Jon Yurek committed Nov 8, 2013
1 parent ba6b93e commit d03a67f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/cocaine/command_line.rb
Expand Up @@ -74,8 +74,8 @@ def run(interpolations = {})
full_command = command(interpolations)
log("#{colored("Command")} :: #{full_command}")
output = execute(full_command)
rescue Errno::ENOENT
raise Cocaine::CommandNotFoundError
rescue Errno::ENOENT => e
raise Cocaine::CommandNotFoundError, e.message
ensure
@exit_status = $?.exitstatus if $?.respond_to?(:exitstatus)
end
Expand Down
11 changes: 11 additions & 0 deletions spec/cocaine/command_line_spec.rb
Expand Up @@ -312,5 +312,16 @@
cmd.runner.class.should eq Cocaine::CommandLine::FakeRunner
end

it 'passes error message to exception when command is failed with Errono::ENOENT' do
cmd = Cocaine::CommandLine.new('test command', '')
cmd.stubs(:execute).with('test command') do
raise Errno::ENOENT, 'fail message'
end
begin
cmd.run
rescue Cocaine::CommandNotFoundError => e
expect(e.message).to eq 'No such file or directory - fail message'
end
end
end
end

0 comments on commit d03a67f

Please sign in to comment.