瀏覽代碼

Conditionally raise error

Christopher Mullins 6 年之前
父節點
當前提交
b10d676967
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      test/remote/lib/mqtt_client.rb

+ 2 - 2
test/remote/lib/mqtt_client.rb

@@ -70,7 +70,7 @@ class MqttClient
     end
   end
 
-  def on_message(topic, timeout = 10, &block)
+  def on_message(topic, timeout = 10, raise_error = true, &block)
     @listen_threads << Thread.new do
       begin
         Timeout.timeout(timeout) do
@@ -81,7 +81,7 @@ class MqttClient
         end
       rescue Timeout::Error => e
         puts "Timed out listening for message on: #{topic}"
-        raise e
+        raise e if raise_error
       rescue BreakListenLoopError
       end
     end