From 6bf221da5f0f2c2139a23f5a067935e6756d4131 Mon Sep 17 00:00:00 2001 From: qcqcqc <1220204124@zust.edu.cn> Date: Tue, 11 Nov 2025 11:02:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=8ErequireSth=E5=8A=A0=E8=BD=BDEx?= =?UTF-8?q?ceptionHandler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/AppLoader.d.ts | 1 + lib/AppLoader.js | 9 +++++++++ src/AppLoader.ts | 13 ++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/AppLoader.d.ts b/lib/AppLoader.d.ts index cab1c85..22d1038 100644 --- a/lib/AppLoader.d.ts +++ b/lib/AppLoader.d.ts @@ -19,6 +19,7 @@ export declare class AppLoader this.registerInternalErrorHandler(handler)); + } + else { + console.warn('lib/configuration/exception必须默认导出一个处理器数组,当前导出类型不正确,将忽略此配置'); + } + } /** * 注册一个内部错误处理器 * @param handler 内部错误处理器 diff --git a/src/AppLoader.ts b/src/AppLoader.ts index 36a2322..8116936 100644 --- a/src/AppLoader.ts +++ b/src/AppLoader.ts @@ -36,6 +36,17 @@ export class AppLoader = {}; private internalErrorHandlers = new Array>(); + public regAllExceptionHandler() { + const handlers = this.requireSth('lib/configuration/exception') as Array> | InternalErrorHandler; + if (Array.isArray(handlers)) { + handlers.forEach( + (handler) => this.registerInternalErrorHandler(handler) + ); + } else { + console.warn('lib/configuration/exception必须默认导出一个处理器数组,当前导出类型不正确,将忽略此配置'); + } + } + /** * 注册一个内部错误处理器 * @param handler 内部错误处理器 @@ -626,7 +637,7 @@ export class AppLoader