()
| 101 | |
| 102 | @contextlib.contextmanager |
| 103 | def _handle_exceptions() -> Iterator[None]: |
| 104 | try: |
| 105 | yield |
| 106 | except Exception as error: |
| 107 | # On error, we should we mimic the compiler-explorer Python wrapper's behavior |
| 108 | # in its traceback-hiding and exit code. |
| 109 | messages = traceback.format_exception_only(type(error), error) |
| 110 | sys.stderr.writelines(messages) |
| 111 | sys.exit(255) |
| 112 | |
| 113 | |
| 114 | @contextlib.contextmanager |