1
0
Fork 0
mirror of synced 2024-06-26 18:20:50 +12:00
Rare/rare/lgndr/api_exception.py
loathingKernel bbaff5f42c Lgndr: Add re-implemented uinstall_game
Lgndr: Change the exception level to CRITICAL for core
LegendaryUtils: Use uninstall_game from our Lgndr
UninstallDialog: Update to return a tuple of values
App: Keep files if the install directory was lost
App: Run legendary's exit procedures on exit
2022-08-02 10:42:38 +03:00

33 lines
1.1 KiB
Python

import logging
import warnings
class LgndrException(RuntimeError):
def __init__(self, message="Error in Legendary"):
self.message = message
super(LgndrException, self).__init__(self.message)
class LgndrWarning(RuntimeWarning):
def __init__(self, message="Warning in Legendary"):
self.message = message
super(LgndrWarning, self).__init__(self.message)
class LgndrCLILogHandler(logging.Handler):
def emit(self, record: logging.LogRecord) -> None:
# lk: FATAL is the same as CRITICAL
if record.levelno == logging.ERROR or record.levelno == logging.CRITICAL:
raise LgndrException(record.getMessage())
# if record.levelno < logging.ERROR or record.levelno == logging.WARNING:
# warnings.warn(record.getMessage())
class LgndrCoreLogHandler(logging.Handler):
def emit(self, record: logging.LogRecord) -> None:
# lk: FATAL is the same as CRITICAL
if record.levelno == logging.CRITICAL:
raise LgndrException(record.getMessage())
# if record.levelno < logging.CRITICAL:
# warnings.warn(record.getMessage())