def testRegisterExceptionClass(self):
     with self.assertRaises(TypeError):
         pywrap_tfe.TFE_Py_RegisterExceptionClass(str)
     pywrap_tfe.TFE_Py_RegisterExceptionClass(core._NotOkStatusException)  # pylint: disable=protected-access
Example #2
0
        return errors.UnknownError(None, None, message, code)


class _NotOkStatusException(Exception):
    """Exception class to handle not ok Status."""
    def __init__(self, message, code):
        super(_NotOkStatusException, self).__init__()
        self.message = message
        self.code = code

    def __str__(self):
        e = _status_to_exception(self.code, self.message)
        return "%s: %s" % (e.__class__.__name__, e)


pywrap_tfe.TFE_Py_RegisterExceptionClass(_NotOkStatusException)


class _FallbackException(Exception):
    """Exception class to handle fallback from the fastpath.

  The fastpath that we refer to here is the one implemented to reduce per-op
  overheads (TFE_Py_FastPathExecute_C). If the conditions for executing the op
  on the fastpath are not met, we fallback to a safer (and more complete)
  slowpath, and this Exception is raised to signal that transition.
  """
    pass


class _SymbolicException(Exception):
    """Exception class to handle use of symbolic tensors when executing eagerly.