Exit after an error in EM

Stephen Paul Weber created

Change summary

lib/blather_notify.rb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Detailed changes

lib/blather_notify.rb 🔗

@@ -14,7 +14,8 @@ module BlatherNotify
 		# workqueue_count MUST be 0 or else Blather uses threads!
 		setup(jid, password, nil, nil, nil, nil, workqueue_count: 0)
 
-		EM.error_handler { |e| warn e.message }
+		EM.error_handler(&method(:panic))
+
 		@thread = Thread.new do
 			EM.run do
 				client.run
@@ -23,7 +24,11 @@ module BlatherNotify
 
 		Timeout.timeout(30) { @ready.pop }
 		at_exit { wait_then_exit }
+	end
 
+	def self.panic(e)
+		warn e.message
+		exit 2
 	end
 
 	def self.wait_then_exit