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