mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-02 02:38:30 +02:00
added error.log file when an error was occuring
This commit is contained in:
parent
5466a88c2d
commit
d37ee5a79c
2 changed files with 8 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
/.idea/
|
/.idea/
|
||||||
/.cache/
|
/.cache/
|
||||||
/option.json
|
/option.json
|
||||||
|
/error.log
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import traceback
|
import traceback
|
||||||
|
from pathlib import Path
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from source.translation import translate as _
|
from source.translation import translate as _
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
def better_gui_error(func: Callable) -> Callable:
|
def better_gui_error(func: Callable) -> Callable:
|
||||||
|
@ -11,6 +13,10 @@ def better_gui_error(func: Callable) -> Callable:
|
||||||
|
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try: return func(*args, **kwargs)
|
try: return func(*args, **kwargs)
|
||||||
except: messagebox.showerror(_("Error"), traceback.format_exc())
|
except:
|
||||||
|
exc = traceback.format_exc()
|
||||||
|
with Path("error.log").open("a", encoding="utf8") as log_file:
|
||||||
|
log_file.write(f"{'#' * 20}\n{time.strftime('%Y/%M/%d %H:%m:%S')}\n\n{exc}\n\n")
|
||||||
|
messagebox.showerror(_("Error"), exc)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
Loading…
Reference in a new issue