Ejemplo n.º 1
0
def _make_exception(msg, error_code):
    try:
        exc_type = errors.exception_type_from_error_code(error_code)
        # log internal backend engine errors only.
        if error_code == errors.INTERNAL:
            logging.log(logging.WARNING, 'mlmd client %s: %s',
                        exc_type.__name__, msg)
        return exc_type(msg)
    except KeyError:
        return errors.UnknownError(msg)
Ejemplo n.º 2
0
def _make_exception(msg, error_code):
  """Makes an exception with MLMD error code.

  Args:
    msg: Error message.
    error_code: MLMD error code.

  Returns:
    An exception.
  """

  try:
    exc_type = errors.exception_type_from_error_code(error_code)
    return exc_type(msg)
  except KeyError:
    return errors.UnknownError(msg)