def toMemoryError(self, addr, data, ranges): if data is None: return None code = data.get(errors.ERROR_CODE) cmd = self.getCommandString() if len(cmd) > 72: cmd = cmd[0:72] + "..." e = MemoryErrorReport( "TCF command exception:\nCommand: %s\nException: %s\nError code: %d" % ( cmd, errors.toErrorString(data), code), data, addr, ranges) caused_by = data.get(errors.ERROR_CAUSED_BY) if caused_by is not None: e.caused_by = self.toError(caused_by, False) return e
def handleEOS(self): if not self.channel.out_tokens and not self.eos_err_report: self.channel.close() else: x = IOError("Communication channel is closed by remote peer") if self.eos_err_report: try: args = fromJSONSequence(self.eos_err_report) if len(args) > 0 and args[0] is not None: x.caused_by = Exception(errors.toErrorString(args[0])) except IOError: pass self.channel.terminate(x)
def _toSFError(self, data): if data is None: return None error_code = data.get(errors.ERROR_CODE) cmd = self.getCommandString() if len(cmd) > 72: cmd = cmd[0:72] + "..." s = Status(error_code, "TCF command exception:" + "\nCommand: " + cmd + "\nException: " + errors.toErrorString(data) + "\nError code: " + str(error_code), data) caused_by = data.get(errors.ERROR_CAUSED_BY) if caused_by is not None: s.initCause(self.toError(caused_by, False)) return s
def __init__(self, msg, attrs, addr, ranges): super(MemoryErrorReport, self).__init__(msg, attrs) if ranges is None: self.ranges = None else: self.ranges = [] for m in ranges: r = Range() x = m.get(memory.ErrorOffset.RANGE_KEY_ADDR) if isinstance(x, str): y = int(x) else: y = x r.offs = y - addr r.size = m.get(memory.ErrorOffset.RANGE_KEY_SIZE) r.stat = m.get(memory.ErrorOffset.RANGE_KEY_STAT) r.msg = errors.toErrorString(m.get(memory.ErrorOffset.RANGE_KEY_MSG)) assert r.offs >= 0 assert r.size >= 0 self.ranges.append(r) self.ranges.sort()