if the traceback is too long in the gui, only keep the 5 first and 5 last lines of the traceback

This commit is contained in:
Faraphel 2022-08-19 23:58:47 +02:00
parent 92231bde4e
commit 8e801329e0
3 changed files with 17 additions and 3 deletions

View file

@ -95,6 +95,10 @@
"CANNOT_FIND_TOOL": "Can't find tool",
"IN_TOOLS_DIRECTORY": "in the tools directory.",
"CANNOT_EXTRACT_A_DIRECTORY": "Can't extract a directory",
"CANNOT_FIND_SLOT": "Can't find slot"
"CANNOT_FIND_SLOT": "Can't find slot",
"FORBIDDEN_TRACKGROUP_ATTRIBUTE": "Forbidden TrackGroup attribute",
"SAFE_EVAL_ERROR": "Safe eval error",
"TEMPLATE_USED": "Template used",
"MORE_IN_ERROR_LOG": "More information in the error.log file"
}
}

View file

@ -96,6 +96,10 @@
"CANNOT_FIND_TOOL": "Impossible de trouver l'outil",
"IN_TOOLS_DIRECTORY": "dans le dossier des outils.",
"CANNOT_EXTRACT_A_DIRECTORY": "Impossible d'extraire un dossier",
"CANNOT_FIND_SLOT": "Impossible de trouver le slot"
"CANNOT_FIND_SLOT": "Impossible de trouver le slot",
"FORBIDDEN_TRACKGROUP_ATTRIBUTE": "Attribut de groupe de course interdit",
"SAFE_EVAL_ERROR": "Erreur lors d'un safe eval",
"TEMPLATE_USED": "Modèle utilisé",
"MORE_IN_ERROR_LOG": "Plus d'information dans le fichier error.log"
}
}

View file

@ -25,6 +25,12 @@ def better_gui_error(func: Callable) -> Callable:
f"{exc}\n"
f"\n"
)
messagebox.showerror(_("Error"), exc)
exc_split = exc.splitlines()
if len(exc_split) > 10:
# if the traceback is too long, only keep the 5 first and 5 last lines of the traceback
exc_split = exc_split[:5] + ["..."] + exc_split[-5:] + ["", "", _("MORE_IN_ERROR_LOG")]
messagebox.showerror(_("Error"), "\n".join(exc_split))
return wrapper