If you want a catch-all error handler, try EM.error_handler. Example from docs :
EM.error_handler{ |e| puts "Error raised during event loop: #{e.message}" }
You may also need finer error handling, in which case you can use the errback mechanism (see Deferrable ). So, for example, you could have in your loop reactor:
EventMachine::run do server = EventMachine::start_server('0.0.0.0', PORT, MyServer) server.errback {
For this to work, include Deferrable on your MyServer, then whenever you want to raise an error, call fail .
Eric G
source share