Emit a warning, providing the user with source file information and the offending code.
(msg)
| 276 | |
| 277 | |
| 278 | def 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 | |
| 297 | def _format_missing_source_error(function, filename): |
no test coverage detected