1
0
Fork 0
mirror of synced 2024-06-23 08:40:45 +12:00

Use custom exception to overload log.error and log.fatal in egl_import and egl_export

This commit is contained in:
loathingKernel 2022-06-25 21:51:32 +03:00
parent 3ec8973de8
commit d4718f823f
2 changed files with 24 additions and 0 deletions

View file

@ -10,10 +10,14 @@ from legendary.utils.selective_dl import get_sdl_appname
from legendary.core import LegendaryCore as LegendaryCoreReal
from .manager import DLManager
from .exception import LgndrException
class LegendaryCore(LegendaryCoreReal):
def __log_exception(self, error):
raise LgndrException(error)
def prepare_download(self, app_name: str, base_path: str = '',
status_q: Queue = None, max_shm: int = 0, max_workers: int = 0,
force: bool = False, disable_patching: bool = False,
@ -225,3 +229,19 @@ class LegendaryCore(LegendaryCoreReal):
self.log.info('Deleting now untagged files.')
self.uninstall_tag(old_igame)
self.install_game(old_igame)
def egl_import(self, app_name):
__log_error = self.log.error
__log_fatal = self.log.fatal
self.log.error = self.__log_exception
self.log.fatal = self.__log_exception
super(LegendaryCore, self).egl_import(app_name)
self.log.error = __log_error
self.log.fatal = __log_fatal
def egl_export(self, app_name):
__log_error = self.log.error
self.log.error = self.__log_exception
super(LegendaryCore, self).egl_export(app_name)
self.log.error = __log_error

4
rare/lgndr/exception.py Normal file
View file

@ -0,0 +1,4 @@
class LgndrException(RuntimeError):
def __init__(self, message="Error in Legendary"):
self.message = message
super(LgndrException, self).__init__(self.message)