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