Report overlay ready in case of no match

This commit is contained in:
pagedown
2022-03-25 22:52:35 +08:00
parent 0c4b20aa4e
commit 16c6545e93
4 changed files with 19 additions and 12 deletions

View File

@@ -50,15 +50,22 @@ def human_size(
return format_number(size / 1024**exponent, max_num_of_decimals) + sep + unit_list[exponent]
def report_unhandled_error(msg: str = '') -> None:
' Report an unhandled exception also sending the overlay ready message to ensure kitten is visible '
def report_error(msg: str = '', return_code: int = 1, print_exc: bool = False) -> None:
' Report an error also sending the overlay ready message to ensure kitten is visible '
from .operations import overlay_ready
print(end=overlay_ready())
if msg:
print(msg, file=sys.stderr)
cls, e, tb = sys.exc_info()
if e and not isinstance(e, (SystemExit, KeyboardInterrupt)):
import traceback
traceback.print_exc()
input('Press Enter to quit.')
raise SystemExit(1)
if print_exc:
cls, e, tb = sys.exc_info()
if e and not isinstance(e, (SystemExit, KeyboardInterrupt)):
import traceback
traceback.print_exc()
with suppress(KeyboardInterrupt, EOFError):
input('Press Enter to quit')
raise SystemExit(return_code)
def report_unhandled_error(msg: str = '') -> None:
' Report an unhandled exception with the overlay ready message '
return report_error(msg, print_exc=True)