diff --git a/glitch/exceptions.py b/glitch/exceptions.py index 72b66aa..f7da3b3 100644 --- a/glitch/exceptions.py +++ b/glitch/exceptions.py @@ -1,6 +1,8 @@ import sys import traceback +from typing import List + EXCEPTIONS = { "ANSIBLE_PLAYBOOK": "Ansible - File is not a playbook: {}", "ANSIBLE_TASKS_FILE": "Ansible - File is not a tasks file: {}", @@ -20,5 +22,8 @@ def throw_exception(exception: str, *args: str) -> None: print("Error:", exception.format(*args), file=sys.stderr) print("=" * 20 + " Traceback " + "=" * 20, file=sys.stderr) - traceback.print_exc(file=sys.stderr) + exc: List[str] = traceback.format_exc().split("\n") + if len(exc) > 40: + exc = exc[:20] + ["..."] + exc[-20:] + print("\n".join(exc), file=sys.stderr) print("=" * 51, file=sys.stderr)