mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
cleaner error messages for authentication failures and command errors (closes #6374)
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@5775 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
46e1b364cf
commit
89b1a46ebf
3 changed files with 17 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Cleaner error messages for authentication failures and command errors
|
||||
|
||||
* Added support for ~/.caprc, also -x and -c switches.
|
||||
|
||||
* Updated migrate action to use db:migrate task in Rails instead of the deprecated migrate task [DHH]
|
||||
|
|
|
@ -269,6 +269,8 @@ DETAIL
|
|||
|
||||
actor = config.actor
|
||||
options[:actions].each { |action| actor.send action }
|
||||
rescue Exception => error
|
||||
handle_error(error)
|
||||
end
|
||||
|
||||
# Load the Rails generator and apply it to the specified directory.
|
||||
|
@ -325,5 +327,15 @@ DETAIL
|
|||
def look_for_raw_actions!
|
||||
@options[:actions].concat(@args)
|
||||
end
|
||||
|
||||
def handle_error(error)
|
||||
case error
|
||||
when Net::SSH::AuthenticationFailed
|
||||
abort "authentication failed for `#{error.message}'"
|
||||
when Capistrano::Command::Error
|
||||
abort(error.message)
|
||||
else raise error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ module Capistrano
|
|||
# This class encapsulates a single command to be executed on a set of remote
|
||||
# machines, in parallel.
|
||||
class Command
|
||||
class Error < RuntimeError; end
|
||||
|
||||
attr_reader :servers, :command, :options, :actor
|
||||
|
||||
def initialize(servers, command, callback, options, actor) #:nodoc:
|
||||
|
@ -42,7 +44,7 @@ module Capistrano
|
|||
logger.trace "command finished"
|
||||
|
||||
if failed = @channels.detect { |ch| ch[:status] != 0 }
|
||||
raise "command #{@command.inspect} failed on #{failed[:host]}"
|
||||
raise Error, "command #{@command.inspect} failed on #{failed[:host]}"
|
||||
end
|
||||
|
||||
self
|
||||
|
|
Loading…
Reference in a new issue