mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-18 15:33:03 +08:00
chore(utils): 配置文件读写器异常改为中文
This commit is contained in:
@@ -52,13 +52,13 @@ class ConfigReader:
|
|||||||
with open(self.__config_path, 'r', encoding='utf-8') as file:
|
with open(self.__config_path, 'r', encoding='utf-8') as file:
|
||||||
self.__config_data = json.load(file)
|
self.__config_data = json.load(file)
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
raise Exception(f"Config file not found: {self.__config_path}") from e
|
raise Exception(f"配置文件不存在: {self.__config_path}") from e
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
raise Exception(f"Without enough permission to read config file: {self.__config_path}") from e
|
raise Exception(f"没有足够的权限读取配置文件: {self.__config_path}") from e
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as e:
|
||||||
raise Exception(f"JSON decode error in config file: {self.__config_path}") from e
|
raise Exception(f"JSON 解析错误: {self.__config_path}") from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"Unknown error occurred while reading config file: {e}") from e
|
raise Exception(f"读取配置文件时未知错误: {e}") from e
|
||||||
|
|
||||||
|
|
||||||
def getConfigs(
|
def getConfigs(
|
||||||
|
|||||||
@@ -58,13 +58,13 @@ class ConfigWriter:
|
|||||||
with open(self.__config_path, "w", encoding="utf-8") as f:
|
with open(self.__config_path, "w", encoding="utf-8") as f:
|
||||||
json.dump(self.__config_data, f, indent=4, sort_keys=False)
|
json.dump(self.__config_data, f, indent=4, sort_keys=False)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
raise Exception(f"Without enough permission to write config file: {self.__config_path}") from e
|
raise Exception(f"没有足够的权限写入配置文件: {self.__config_path}") from e
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise Exception(f"IO error occurred while writing config file: {self.__config_path}") from e
|
raise Exception(f"写入配置文件时发生 IO 错误: {self.__config_path}") from e
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
raise Exception(f"Config data contains invalid type that can not be JSON serialized: {e}") from e
|
raise Exception(f"配置数据包含无法 JSON 序列化的类型: {e}") from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"Unknown error occurred while writing config file: {e}") from e
|
raise Exception(f"写入配置文件时未知错误: {e}") from e
|
||||||
|
|
||||||
|
|
||||||
def setConfigs(
|
def setConfigs(
|
||||||
|
|||||||
Reference in New Issue
Block a user