From 85e36c461c73a8d722eb9d65652dc231973f37e3 Mon Sep 17 00:00:00 2001 From: Faraphel Date: Fri, 21 Jan 2022 22:41:45 +0100 Subject: [PATCH] moved all error to Error.py --- source/Error.py | 33 +++++++++++++++++++++++++++++++++ source/Game.py | 21 +-------------------- source/Option.py | 2 +- source/Track.py | 16 +--------------- 4 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 source/Error.py diff --git a/source/Error.py b/source/Error.py new file mode 100644 index 0000000..68c3454 --- /dev/null +++ b/source/Error.py @@ -0,0 +1,33 @@ +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 !") diff --git a/source/Game.py b/source/Game.py index 0a0486a..9220f14 100644 --- a/source/Game.py +++ b/source/Game.py @@ -7,26 +7,7 @@ import json from source.CT_Config import CT_Config from source.definition import * from source.wszst import * - - -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 !") +from source.Error import * class NoGui: diff --git a/source/Option.py b/source/Option.py index 7d3db7b..c72ce32 100644 --- a/source/Option.py +++ b/source/Option.py @@ -1,7 +1,7 @@ import json import os -from .definition import restart +from source.definition import restart class Option: diff --git a/source/Track.py b/source/Track.py index b5a917c..5eaed2a 100644 --- a/source/Track.py +++ b/source/Track.py @@ -1,20 +1,6 @@ from source.definition import * from source.wszst import * - - -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 !") +from source.Error import * def get_trackdata_from_json(track_json, *args, **kwargs):