def _EncodeOpError(err):
  if isinstance(err, errors.GenericError):
    to_encode = err
  else:
    to_encode = errors.OpExecError(str(err))

  return errors.EncodeException(to_encode)
Encodes an error which occurred while processing an opcode.
dataset/ETHPy150Open ganeti/ganeti/lib/jqueue/__init__.py/_EncodeOpError