3aae3887f6
Lgndr: Prefix files that aren't part of legendary with 'api_' Lgndr: Return statistics from 'verify_game' instead of parsing the exception VerifyWorker: Add 'error' signal for exceptions.
23 lines
803 B
Python
23 lines
803 B
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 LgndrLogHandler(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.INFO or record.levelno == logging.WARNING:
|
|
# warnings.warn(record.getMessage())
|