异常处理模块

异常处理模块提供统一的异常管理和状态码系统。

异常类

exception Utils.Exceptions.OrionException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:Exception

OrionLauncher异常基类

所有自定义异常都应继承此类,以便于统一处理和识别。

message

异常消息

Type:

str

code

错误代码

Type:

int

details

附加的错误详情

Type:

dict

__init__(message: str, code: int = None, details: dict | None = None)[源代码]

初始化OrionException实例

参数:
  • message (str) -- 异常消息

  • code (int, optional) -- 错误代码,如果为None则自动获取

  • details (dict, optional) -- 附加的错误详情,默认为None

__str__() str[源代码]

返回异常的字符串表示

to_dict() dict[源代码]

将异常转换为字典格式

exception Utils.Exceptions.CoreException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:OrionException

核心模块异常基类

exception Utils.Exceptions.NetworkException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:CoreException

网络相关异常基类

exception Utils.Exceptions.DownloadException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:NetworkException

下载异常

exception Utils.Exceptions.ApiException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:NetworkException

API调用异常

exception Utils.Exceptions.AuthenticationException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:NetworkException

认证异常

exception Utils.Exceptions.FileSystemException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:CoreException

文件系统相关异常基类

exception Utils.Exceptions.FileNotFoundException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:FileSystemException

文件未找到异常

exception Utils.Exceptions.FilePermissionException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:FileSystemException

文件权限异常

exception Utils.Exceptions.FileOperationException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:FileSystemException

文件操作异常

exception Utils.Exceptions.ConfigException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:CoreException

配置相关异常基类

exception Utils.Exceptions.InvalidConfigException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:ConfigException

无效配置异常

exception Utils.Exceptions.ConfigNotFoundException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:ConfigException

配置未找到异常

exception Utils.Exceptions.GameException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:CoreException

游戏相关异常基类

exception Utils.Exceptions.GameLaunchException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:GameException

游戏启动异常

exception Utils.Exceptions.GameInstallException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:GameException

游戏安装异常

exception Utils.Exceptions.ControllerException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:OrionException

控制器异常基类

exception Utils.Exceptions.InitializationException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:ControllerException

初始化异常

exception Utils.Exceptions.AsyncTaskException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:ControllerException

异步任务异常

exception Utils.Exceptions.ViewException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:OrionException

视图异常基类

exception Utils.Exceptions.UIException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:ViewException

UI相关异常

exception Utils.Exceptions.UtilsException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:OrionException

工具异常基类

exception Utils.Exceptions.RepositoryException(message: str, code: int = None, details: dict | None = None)[源代码]

基类:UtilsException

仓库异常

exception Utils.Exceptions.WrappedSystemException(original_exception: Exception, message: str | None = None)[源代码]

基类:OrionException

系统异常包装器

用于包装系统异常,将其转换为OrionException

original_exception

原始系统异常

Type:

Exception

__init__(original_exception: Exception, message: str | None = None)[源代码]

初始化WrappedSystemException实例

参数:
  • original_exception (Exception) -- 原始系统异常

  • message (str, optional) -- 自定义消息,如果为None则使用原始异常消息

Utils.Exceptions.decode_error_code(code: int) dict[源代码]

解析错误状态码的层级信息

参数:

code (int) -- 错误状态码

返回:

包含层级信息的字典

返回类型:

dict

Utils.Exceptions.get_error_code_for_exception(exception_class_name: str) int[源代码]

根据异常类名获取对应的错误状态码

参数:

exception_class_name (str) -- 异常类名

返回:

对应的错误状态码,如果未找到则返回通用错误码

返回类型:

int

Utils.Exceptions.format_error_code(code: int) str[源代码]

格式化错误状态码为可读形式

参数:

code (int) -- 错误状态码

返回:

格式化后的错误状态码字符串

返回类型:

str

异常状态码

OrionLauncher异常状态码定义

异常状态码采用5位数字格式:XYZAB │││││ │││└┴─ 具体异常类型 (01-99) ││└─── 子模块类型 (0-9) │└──── 主模块类型 (0-9) └───── 应用层级 (1-9)

应用层级分配: 1 - Core层异常 2 - Controller层异常 3 - View层异常 4 - Utils层异常 9 - 系统异常包装器

class Utils.Exceptions.code.CoreErrorCodes[源代码]

基类:object

Core层异常状态码

CORE_GENERAL_ERROR = 10001
CORE_INITIALIZATION_ERROR = 10002
CORE_UNKNOWN_ERROR = 10099
NETWORK_GENERAL_ERROR = 11001
NETWORK_CONNECTION_ERROR = 11002
NETWORK_TIMEOUT_ERROR = 11003
NETWORK_DNS_ERROR = 11004
NETWORK_SSL_ERROR = 11005
DOWNLOAD_GENERAL_ERROR = 11101
DOWNLOAD_FILE_NOT_FOUND = 11102
DOWNLOAD_PERMISSION_DENIED = 11103
DOWNLOAD_DISK_FULL = 11104
DOWNLOAD_CHECKSUM_MISMATCH = 11105
DOWNLOAD_INTERRUPTED = 11106
DOWNLOAD_SPEED_TOO_SLOW = 11107
API_GENERAL_ERROR = 11201
API_INVALID_REQUEST = 11202
API_UNAUTHORIZED = 11203
API_FORBIDDEN = 11204
API_NOT_FOUND = 11205
API_SERVER_ERROR = 11206
API_RATE_LIMITED = 11207
API_INVALID_RESPONSE = 11208
AUTH_GENERAL_ERROR = 11301
AUTH_INVALID_CREDENTIALS = 11302
AUTH_TOKEN_EXPIRED = 11303
AUTH_TOKEN_INVALID = 11304
AUTH_PERMISSION_DENIED = 11305
AUTH_ACCOUNT_LOCKED = 11306
AUTH_MFA_REQUIRED = 11307
FILESYSTEM_GENERAL_ERROR = 12001
FILE_NOT_FOUND = 12101
FILE_PERMISSION_DENIED = 12102
FILE_ALREADY_EXISTS = 12103
FILE_IN_USE = 12104
FILE_CORRUPTED = 12105
FILE_TOO_LARGE = 12106
DIRECTORY_NOT_FOUND = 12201
DIRECTORY_PERMISSION_DENIED = 12202
DIRECTORY_NOT_EMPTY = 12203
DIRECTORY_CREATION_FAILED = 12204
CONFIG_GENERAL_ERROR = 13001
CONFIG_NOT_FOUND = 13002
CONFIG_INVALID_FORMAT = 13003
CONFIG_VALIDATION_FAILED = 13004
CONFIG_SAVE_FAILED = 13005
CONFIG_LOAD_FAILED = 13006
GAME_GENERAL_ERROR = 14001
GAME_LAUNCH_FAILED = 14101
GAME_EXECUTABLE_NOT_FOUND = 14102
GAME_INCOMPATIBLE_SYSTEM = 14103
GAME_MISSING_DEPENDENCIES = 14104
GAME_ALREADY_RUNNING = 14105
GAME_INSTALL_FAILED = 14201
GAME_INSTALL_SPACE_INSUFFICIENT = 14202
GAME_INSTALL_CORRUPTED = 14203
GAME_UNINSTALL_FAILED = 14204
class Utils.Exceptions.code.ControllerErrorCodes[源代码]

基类:object

Controller层异常状态码

CONTROLLER_GENERAL_ERROR = 20001
CONTROLLER_INITIALIZATION_FAILED = 20002
ASYNC_TASK_FAILED = 21001
ASYNC_TASK_TIMEOUT = 21002
ASYNC_TASK_CANCELLED = 21003
ASYNC_TASK_QUEUE_FULL = 21004
ACCOUNT_CONTROLLER_ERROR = 22001
ACCOUNT_LOGIN_FAILED = 22002
ACCOUNT_LOGOUT_FAILED = 22003
ACCOUNT_REFRESH_FAILED = 22004
GAME_CONTROLLER_ERROR = 23001
GAME_LIST_LOAD_FAILED = 23002
GAME_INFO_FETCH_FAILED = 23003
SETTINGS_CONTROLLER_ERROR = 24001
SETTINGS_LOAD_FAILED = 24002
SETTINGS_SAVE_FAILED = 24003
class Utils.Exceptions.code.ViewErrorCodes[源代码]

基类:object

View层异常状态码

VIEW_GENERAL_ERROR = 30001
VIEW_INITIALIZATION_FAILED = 30002
UI_COMPONENT_ERROR = 31001
UI_RENDER_ERROR = 31002
UI_EVENT_HANDLER_ERROR = 31003
UI_RESOURCE_LOAD_ERROR = 31004
WINDOW_CREATION_FAILED = 32001
WINDOW_SHOW_FAILED = 32002
WINDOW_CLOSE_FAILED = 32003
DIALOG_CREATION_FAILED = 33001
DIALOG_MODAL_ERROR = 33002
class Utils.Exceptions.code.UtilsErrorCodes[源代码]

基类:object

Utils层异常状态码

UTILS_GENERAL_ERROR = 40001
REPOSITORY_ERROR = 41001
REPOSITORY_PATH_ERROR = 41002
REPOSITORY_ACCESS_ERROR = 41003
class Utils.Exceptions.code.SystemErrorCodes[源代码]

基类:object

系统异常包装器状态码

SYSTEM_EXCEPTION_WRAPPER = 90001
UNKNOWN_SYSTEM_ERROR = 90099
Utils.Exceptions.code.get_error_code_for_exception(exception_class_name: str) int[源代码]

根据异常类名获取对应的错误状态码

参数:

exception_class_name (str) -- 异常类名

返回:

对应的错误状态码,如果未找到则返回通用错误码

返回类型:

int

Utils.Exceptions.code.format_error_code(code: int) str[源代码]

格式化错误状态码为可读形式

参数:

code (int) -- 错误状态码

返回:

格式化后的错误状态码字符串

返回类型:

str

Utils.Exceptions.code.decode_error_code(code: int) dict[源代码]

解析错误状态码的层级信息

参数:

code (int) -- 错误状态码

返回:

包含层级信息的字典

返回类型:

dict