- self.dispatcher.dispatch(msg)
- #try:
- # d.dispatch(msg)
- #except dis.BadRouteError, inst:
- # sock.sendto('Bad route from : ' + inst.cmd + '\n', addr)
- #except dis.CommandNotFoundError, inst:
- # sock.sendto('Command not found : ' + inst.cmd + '\n', addr)
+ try:
+ result = self.dispatcher.dispatch(msg)
+ response = 'OK '
+ except Exception, e:
+ result = str(e)
+ response = 'ERROR '
+ if result is None:
+ response += '0'
+ else:
+ response += '%d\n%s' % (len(str(result)), result)
+ self.file.sendto(response, addr)