An unhandled exception happened during execution. This is raised from Interpreter.exec() and Interpreter.call().
| 33 | """.strip() |
| 34 | |
| 35 | class ExecutionFailed(InterpreterError): |
| 36 | """An unhandled exception happened during execution. |
| 37 | |
| 38 | This is raised from Interpreter.exec() and Interpreter.call(). |
| 39 | """ |
| 40 | |
| 41 | def __init__(self, excinfo): |
| 42 | msg = excinfo.formatted |
| 43 | if not msg: |
| 44 | if excinfo.type and excinfo.msg: |
| 45 | msg = f'{excinfo.type.__name__}: {excinfo.msg}' |
| 46 | else: |
| 47 | msg = excinfo.type.__name__ or excinfo.msg |
| 48 | super().__init__(msg) |
| 49 | self.excinfo = excinfo |
| 50 | |
| 51 | def __str__(self): |
| 52 | try: |
| 53 | formatted = self.excinfo.errdisplay |
| 54 | except Exception: |
| 55 | return super().__str__() |
| 56 | else: |
| 57 | return _EXEC_FAILURE_STR.format( |
| 58 | superstr=super().__str__(), |
| 59 | formatted=formatted, |
| 60 | ) |
| 61 | |
| 62 | |
| 63 | def create(): |