def handle(self, conn): try: mod = id2class[self.class_id] method = getattr(mod, 'id2method')[self.method_id] except: method = None conn.reset() error_code = id2constant.get(self.reply_code, '') logger.warn('Connection Hard Error. code=%r. %s', error_code, self.reply_text) if conn.on_error: try: conn.on_error(ConnectionError(error_code, self.reply_text, method)) except Exception: logger.error('ERROR in on_error() callback', exc_info=True)
def handle(self, channel): try: mod = id2class[self.class_id] method = getattr(mod, 'id2method')[self.method_id] except: method = None raise channel.reset() error_code = id2constant.get(self.reply_code, '') logger.warn('Soft Error. channel=%r code=%r. %s', channel.channel_id, error_code, self.reply_text) if channel.on_error: try: channel.on_error(ChannelError(error_code, self.reply_text, method)) except Exception: logger.error('ERROR in on_error() callback for channel %d', channel.channel_id, exc_info=True)