mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-18 00:35:36 +00:00
Add exception handler
This commit is contained in:
parent
61f92c4c08
commit
1cf9a07f69
@ -8,6 +8,7 @@
|
|||||||
# (c) kuitoi.su 2023
|
# (c) kuitoi.su 2023
|
||||||
import builtins
|
import builtins
|
||||||
import json
|
import json
|
||||||
|
from json import JSONDecodeError
|
||||||
|
|
||||||
from core.utils import get_logger
|
from core.utils import get_logger
|
||||||
|
|
||||||
@ -60,8 +61,11 @@ class MultiLanguage:
|
|||||||
try:
|
try:
|
||||||
with open(file, encoding=self.__encoding) as f:
|
with open(file, encoding=self.__encoding) as f:
|
||||||
self.__data.update(json.load(f))
|
self.__data.update(json.load(f))
|
||||||
|
return
|
||||||
|
except JSONDecodeError:
|
||||||
|
self.log.error(f"Localisation \"{self.language}.json\" have JsonDecodeError. Using default localisation: en.")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.log.warning(f"Localisation {self.language} not found; Setting language to: en.")
|
self.log.warning(f"Localisation \"{self.language}.json\" not found; Using default localisation: en.")
|
||||||
self.set_language("en")
|
self.set_language("en")
|
||||||
|
|
||||||
def builtins_hook(self) -> None:
|
def builtins_hook(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user