public
Description: Remote multi-server automation tool
Homepage: http://www.capify.org
Clone URL: git://github.com/jamis/capistrano.git
Search Repo:
Make the "no matching servers" error more sane (closes #8828)


git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@7205 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jamis (author)
Sat Jul 21 14:51:44 -0700 2007
commit  4e64823c9347718cae595cd8096371c1961a29c4
tree    92641e37a819852999c106ae600a53f0d3ede6d8
parent  f77c785f38c14b5dc390e1c89a8a86522d148cd1
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Make the "no matching servers" error more sane [halorgium]
0
+
0
 * Make sure the invoke task gives a sane error when the COMMAND value is omitted [halorgium]
0
 
0
 * Make sure variables are conditionally set in the deploy recipes, so as not to clobber values set elsewhere [Jamis Buck]
...
105
106
107
108
 
109
110
111
...
114
115
116
117
 
118
119
120
...
105
106
107
 
108
109
110
111
...
114
115
116
 
117
118
119
120
0
@@ -105,7 +105,7 @@ module Capistrano
0
           servers = find_servers_for_task(task, options)
0
 
0
           if servers.empty?
0
- raise ScriptError, "`#{task.fully_qualified_name}' is only run for servers matching #{task.options.inspect}, but no servers matched"
0
+ raise Capistrano::NoMatchingServersError, "`#{task.fully_qualified_name}' is only run for servers matching #{task.options.inspect}, but no servers matched"
0
           end
0
 
0
           if task.continue_on_error?
0
@@ -114,7 +114,7 @@ module Capistrano
0
           end
0
         else
0
           servers = find_servers(options)
0
- raise ScriptError, "no servers found to match #{options.inspect}" if servers.empty?
0
+ raise Capistrano::NoMatchingServersError, "no servers found to match #{options.inspect}" if servers.empty?
0
         end
0
 
0
         servers = [servers.first] if options[:once]
...
3
4
5
 
6
7
8
...
3
4
5
6
7
8
9
0
@@ -3,6 +3,7 @@ module Capistrano
0
 
0
   class CaptureError < Error; end
0
   class NoSuchTaskError < Error; end
0
+ class NoMatchingServersError < Error; end
0
   
0
   class RemoteError < Error
0
     attr_accessor :hosts
...
160
161
162
163
 
164
165
166
...
160
161
162
 
163
164
165
166
0
@@ -160,7 +160,7 @@ HELP
0
           connect(task)
0
           configuration.execute_task(task)
0
         end
0
- rescue Capistrano::NoSuchTaskError => error
0
+ rescue Capistrano::NoMatchingServersError, Capistrano::NoSuchTaskError => error
0
         warn "error: #{error.message}"
0
       end
0
 
...
3
4
5
6
 
7
8
9
 
 
10
11
12
13
 
14
15
16
...
28
29
30
31
 
32
33
34
...
61
62
63
64
 
65
66
67
68
...
3
4
5
 
6
7
8
9
10
11
12
13
14
 
15
16
17
18
...
30
31
32
 
33
34
35
36
...
63
64
65
 
66
67
68
69
70
0
@@ -3,14 +3,16 @@ require 'capistrano/server_definition'
0
 module Capistrano
0
   # Represents the definition of a single task.
0
   class TaskDefinition
0
- attr_reader :name, :namespace, :options, :body
0
+ attr_reader :name, :namespace, :options, :body, :desc, :on_error
0
 
0
     def initialize(name, namespace, options={}, &block)
0
       @name, @namespace, @options = name, namespace, options
0
+ @desc = @options.delete(:desc)
0
+ @on_error = options.delete(:on_error)
0
       @body = block or raise ArgumentError, "a task requires a block"
0
       @servers = nil
0
     end
0
-
0
+
0
     # Returns the task's fully-qualified name, including the namespace
0
     def fully_qualified_name
0
       @fully_qualified_name ||= begin
0
@@ -28,7 +30,7 @@ module Capistrano
0
     def description(rebuild=false)
0
       @description = nil if rebuild
0
       @description ||= begin
0
- description = options[:desc] || ""
0
+ description = @desc || ""
0
 
0
         indentation = description[/\A\s+/]
0
         if indentation
0
@@ -61,7 +63,7 @@ module Capistrano
0
     # Indicates whether the task wants to continue, even if a server has failed
0
     # previously
0
     def continue_on_error?
0
- options[:on_error] == :continue
0
+ @on_error == :continue
0
     end
0
   end
0
 end
0
\ No newline at end of file
...
138
139
140
141
 
142
143
144
145
146
147
 
148
149
150
...
138
139
140
 
141
142
143
144
145
146
 
147
148
149
150
0
@@ -138,13 +138,13 @@ class ConfigurationConnectionsTest < Test::Unit::TestCase
0
 
0
   def test_execute_on_servers_without_current_task_should_raise_error_if_no_matching_servers
0
     @config.expects(:find_servers).with(:a => :b, :c => :d).returns([])
0
- assert_raises(ScriptError) { @config.execute_on_servers(:a => :b, :c => :d) { |list| } }
0
+ assert_raises(Capistrano::NoMatchingServersError) { @config.execute_on_servers(:a => :b, :c => :d) { |list| } }
0
   end
0
 
0
   def test_execute_on_servers_should_raise_an_error_if_the_current_task_has_no_matching_servers_by_default
0
     @config.current_task = mock_task
0
     @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([])
0
- assert_raises(ScriptError) do
0
+ assert_raises(Capistrano::NoMatchingServersError) do
0
       @config.execute_on_servers do
0
         flunk "should not get here"
0
       end
...
58
59
60
61
62
 
 
63
64
65
66
67
68
 
69
70
71
...
58
59
60
 
 
61
62
63
64
65
66
67
 
68
69
70
71
0
@@ -58,14 +58,14 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
0
     @config.desc "A description"
0
     @config.task(:testing) { puts "foo" }
0
     @config.task(:another) { puts "bar" }
0
- assert_equal "A description", @config.tasks[:testing].options[:desc]
0
- assert_nil @config.tasks[:another].options[:desc]
0
+ assert_equal "A description", @config.tasks[:testing].desc
0
+ assert_nil @config.tasks[:another].desc
0
   end
0
 
0
   def test_pending_desc_should_apply_only_to_next_task_in_any_namespace
0
     @config.desc "A description"
0
     @config.namespace(:outer) { task(:testing) { puts "foo" } }
0
- assert_equal "A description", @config.namespaces[:outer].tasks[:testing].options[:desc]
0
+ assert_equal "A description", @config.namespaces[:outer].tasks[:testing].desc
0
   end
0
 
0
   def test_defining_task_without_block_should_raise_error

Comments

    No one has commented yet.