MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / emitWarning

Function emitWarning

python/cudaq/kernel/utils.py:278–294  ·  view source on GitHub ↗

Emit a warning, providing the user with source file information and the offending code.

(msg)

Source from the content-addressed store, hash-verified

276
277
278def emitWarning(msg):
279 """
280 Emit a warning, providing the user with source file information and
281 the offending code.
282 """
283 print(Color.BOLD, end='')
284 try:
285 # Raise the exception so we can get the stack trace to inspect
286 raise RuntimeError(msg)
287 except RuntimeError:
288 # Immediately grab the exception and analyze the stack trace, getting
289 # the source location and construct a new error diagnostic
290 with set_tracebacklimit(None):
291 offendingSrc = traceback.format_stack()
292 if len(offendingSrc):
293 msg = (Color.YELLOW + "error: " + Color.END + Color.BOLD + msg +
294 Color.END + '\n\nOffending code:\n' + offendingSrc[0])
295
296
297def _format_missing_source_error(function, filename):

Callers 3

mlirTypeFromAnnotationFunction · 0.85
initializeMethod · 0.85
TraverseRecordTypeMethod · 0.85

Calls 2

set_tracebacklimitFunction · 0.85
printFunction · 0.50

Tested by

no test coverage detected