From c5130f36d5024d00dd2615de7f12fc5de2339c72 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 11 Aug 2021 15:14:29 -0500 Subject: [PATCH] Exit after an error in EM --- lib/blather_notify.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/blather_notify.rb b/lib/blather_notify.rb index d9c3846b4dbdb1cfcd445e6d48da87e001f47e74..9024a733fb7ceca884acd58607c99765ccce6bbf 100644 --- a/lib/blather_notify.rb +++ b/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