Commit f6b6db58 authored by Philip ABBET's avatar Philip ABBET

The 'MessageHandler' class now catches the new RemoteException

parent 33a1ce01
......@@ -38,6 +38,7 @@ monkey.patch_socket(dns=False)
monkey.patch_ssl()
from . import baseformat
from .inputs import RemoteException
class MessageHandler(gevent.Greenlet):
......@@ -116,6 +117,17 @@ class MessageHandler(gevent.Greenlet):
if command in self.callbacks:
try: #to handle command
self.callbacks[command](*parts[1:])
except RemoteException as e:
if e.system_error != '':
self.send_error(e.system_error, kind='sys')
self.system_error = e.system_error
else:
self.send_error(e.user_error, kind='usr')
self.user_error = e.user_error
if self.process is not None:
self.process.kill()
self.stop.set()
break
except:
import traceback
parser = lambda s: s if len(s)<20 else s[:20] + '...'
......@@ -291,12 +303,12 @@ class MessageHandler(gevent.Greenlet):
self.must_kill.set()
def send_error(self, message):
def send_error(self, message, kind='usr'):
"""Sends a user (usr) or system (sys) error message to the infrastructure"""
logger.debug('send: (err) error')
self.socket.send('err', zmq.SNDMORE)
self.socket.send('usr', zmq.SNDMORE)
self.socket.send(kind, zmq.SNDMORE)
logger.debug('send: """%s"""' % message.rstrip())
self.socket.send(message)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment