MCPcopy Index your code
hub / github.com/dmlc/dgl / reraise

Method reraise

python/dgl/utils/exception.py:39–61  ·  view source on GitHub ↗

r"""Reraises the wrapped exception in the current thread

(self)

Source from the content-addressed store, hash-verified

37 self.where = where
38
39 def reraise(self):
40 r"""Reraises the wrapped exception in the current thread"""
41 # Format a message such as: "Caught ValueError in DataLoader worker
42 # process 2. Original Traceback:", followed by the traceback.
43 msg = "Caught {} {}.\nOriginal {}".format(
44 self.exc_type.__name__, self.where, self.exc_msg
45 )
46 if self.exc_type == KeyError:
47 # KeyError calls repr() on its argument (usually a dict key). This
48 # makes stack traces unreadable. It will not be changed in Python
49 # (https://bugs.python.org/issue2651), so we work around it.
50 msg = KeyErrorMessage(msg)
51 elif getattr(self.exc_type, "message", None):
52 # Some exceptions have first argument as non-str but explicitly
53 # have message field
54 raise self.exc_type(message=msg)
55 try:
56 exception = self.exc_type(msg)
57 except TypeError:
58 # If the exception takes multiple arguments, don't try to
59 # instantiate since we don't know how to
60 raise RuntimeError(msg) from None
61 raise exception

Callers 1

_next_threadedMethod · 0.80

Calls 2

KeyErrorMessageClass · 0.85
formatMethod · 0.80

Tested by

no test coverage detected