mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 19:28:25 +02:00
63 lines
No EOL
1.8 KiB
Python
63 lines
No EOL
1.8 KiB
Python
from tkinter import messagebox
|
|
import traceback
|
|
import os
|
|
|
|
|
|
class RomAlreadyPatched(Exception):
|
|
def __init__(self):
|
|
super().__init__("ROM Already patched !")
|
|
|
|
|
|
class InvalidGamePath(Exception):
|
|
def __init__(self):
|
|
super().__init__("This path is not valid !")
|
|
|
|
|
|
class InvalidFormat(Exception):
|
|
def __init__(self):
|
|
super().__init__("This game format is not supported !")
|
|
|
|
|
|
class TooMuchSha1CheckFailed(Exception):
|
|
def __init__(self):
|
|
super().__init__("Too much sha1 check failed !")
|
|
|
|
|
|
class CantDownloadTrack(Exception):
|
|
def __init__(self, track, http_error: [str, int]):
|
|
super().__init__(f"Can't download track {track.name} ({track.sha1}) (error {http_error}) !")
|
|
|
|
|
|
class CantConvertTrack(Exception):
|
|
def __init__(self):
|
|
super().__init__("Can't convert track.")
|
|
|
|
|
|
class MissingTrackWU8(Exception):
|
|
def __init__(self):
|
|
super().__init__("The original wu8 track file is missing !")
|
|
|
|
|
|
class ErrorLogger:
|
|
def __init__(self, common):
|
|
self.common = common
|
|
|
|
def log_error(self) -> None:
|
|
"""
|
|
When an error occur, will show it in a messagebox and write it in error.log
|
|
"""
|
|
error = traceback.format_exc()
|
|
with open("./error.log", "a") as f:
|
|
f.write(
|
|
f"---\n"
|
|
f"For game version : {self.common.ct_config.version}\n"
|
|
f"./file/ directory : {os.listdir('./file/')}\n"
|
|
f"ctconfig directory : {os.listdir(self.common.ct_config.pack_path)}\n"
|
|
f"GAME/files/ information : {self.common.game.path, self.common.game.region}\n"
|
|
f"{error}\n"
|
|
)
|
|
|
|
messagebox.showerror(
|
|
self.common.translate("Error"),
|
|
self.common.translate("An error occured", " :", "\n", error, "\n\n")
|
|
) |