diff options
| author | Luke Kanies <luke@madstop.com> | 2009-05-12 22:12:45 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-05-18 17:07:18 +1000 |
| commit | 4bf2980577c2e1233b7102540237aae01c70bde5 (patch) | |
| tree | 31ef01e4be4cce9c24420318288d1aeea35572c1 | |
| parent | f4cb8f36dfb2ae05d64ef609d03795537b0720fa (diff) | |
| download | puppet-4bf2980577c2e1233b7102540237aae01c70bde5.tar.gz puppet-4bf2980577c2e1233b7102540237aae01c70bde5.tar.xz puppet-4bf2980577c2e1233b7102540237aae01c70bde5.zip | |
Protecting Stomp client against internal failures
Apparently the stomp client is really unhelpful with
failures; this attempts to provide at least a bit
more information.
Signed-off-by: Luke Kanies <luke@madstop.com>
| -rw-r--r-- | lib/puppet/util/queue/stomp.rb | 6 | ||||
| -rwxr-xr-x | spec/unit/util/queue/stomp.rb | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/puppet/util/queue/stomp.rb b/lib/puppet/util/queue/stomp.rb index 3a6a99ca2..62716fab2 100644 --- a/lib/puppet/util/queue/stomp.rb +++ b/lib/puppet/util/queue/stomp.rb @@ -21,7 +21,11 @@ class Puppet::Util::Queue::Stomp raise ArgumentError, "Could not create Stomp client instance - queue source %s is not a Stomp URL: %s" % [Puppet[:queue_source], detail] end - self.stomp_client = Stomp::Client.new(uri.user, uri.password, uri.host, uri.port, true) + begin + self.stomp_client = Stomp::Client.new(uri.user, uri.password, uri.host, uri.port, true) + rescue => detail + raise ArgumentError, "Could not create Stomp client instance with queue source %s: got internal Stomp client error %s" % [Puppet[:queue_source], detail] + end end def send_message(target, msg) diff --git a/spec/unit/util/queue/stomp.rb b/spec/unit/util/queue/stomp.rb index f2960b3f8..2adf320e1 100755 --- a/spec/unit/util/queue/stomp.rb +++ b/spec/unit/util/queue/stomp.rb @@ -45,6 +45,11 @@ describe 'Puppet::Util::Queue::Stomp' do lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError) end + it "should fail somewhat helpfully if the Stomp client cannot be created" do + Stomp::Client.expects(:new).raises RuntimeError + lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError) + end + list = %w{user password host port} {"user" => "myuser", "password" => "mypass", "host" => "foohost", "port" => 42}.each do |name, value| it "should use the #{name} from the queue source as the queueing #{name}" do |
