Skip to content

Commit

Permalink
Merge pull request capistrano#109 from dbackeus/master
Browse files Browse the repository at this point in the history
Better errors when trying to upload non-existent files.

(This patch comes with brittle tests, if you have problems, please report them on the issue tracker.)
  • Loading branch information
leehambley committed Dec 11, 2011
2 parents 45ed097 + a9a51c2 commit a0a58d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/capistrano/transfer.rb
Expand Up @@ -203,6 +203,8 @@ def normalize(argument, session)
end

def handle_error(error)
raise error if error.message.include?('expected a file to upload')

transfer = session_map[error.session]
transfer[:error] = error
transfer[:failed] = true
Expand Down
8 changes: 8 additions & 0 deletions test/transfer_test.rb
Expand Up @@ -133,6 +133,14 @@ def test_errors_raised_for_a_scp_session_should_abort_session_and_continue_with_
transfer.process!
end

def test_uploading_a_non_existing_file_should_raise_an_understandable_error
s = session('app1')
error = Capistrano::Processable::SessionAssociation.on(ArgumentError.new('expected a file to upload'), s)
transfer = Capistrano::Transfer.new(:up, "from", "to", [], :via => :scp)
transfer.expects(:process_iteration).raises(error)
assert_raise(ArgumentError, 'expected a file to upload') { transfer.process! }
end

private

class ExceptionWithSession < ::Exception
Expand Down

0 comments on commit a0a58d0

Please sign in to comment.