diff --git a/lib/server/start.js b/lib/server/start.js index f75ab8a..6719b22 100644 --- a/lib/server/start.js +++ b/lib/server/start.js @@ -39,13 +39,17 @@ function concat(...paths) { }); } async function startup(path, connector, omitWatchers, omitTimers, routine) { - let errorHandler = undefined; - try { - errorHandler = require((0, path_1.join)(path, 'lib', 'configuration', 'exception')).default; - } - catch (err) { - // 不存在exception配置 - } + // let errorHandler: InternalErrorHandler | undefined = undefined; + // try { + // errorHandler = require(join( + // path, + // 'lib', + // 'configuration', + // 'exception' + // )).default; + // } catch (err) { + // // 不存在exception配置 + // } const serverConfiguration = require((0, path_1.join)(path, 'lib', 'configuration', 'server')).default; // 拿到package.json,用作项目的唯一标识,否则无法区分不同项目的Redis+socketIO连接 const packageJson = require((0, path_1.join)(path, 'package.json')); @@ -172,21 +176,22 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) { await appLoader.unmount(); return result; } - if (errorHandler && typeof errorHandler === 'function') { - // polyfillConsole("startup", true, (props) => { - // if (props.level === "error") { - // appLoader.execRoutine(async (ctx) => { - // await errorHandler(props.caller, props.args, ctx); - // }).catch((err) => { - // console.warn('执行全局错误处理失败:', err); - // }); - // } - // return props.args; - // }); - appLoader.registerInternalErrorHandler(async (ctx, type, msg, err, oakErr) => { - await errorHandler(ctx, type, msg, err, oakErr); - }); - } + // if (errorHandler && typeof errorHandler === 'function') { + // // polyfillConsole("startup", true, (props) => { + // // if (props.level === "error") { + // // appLoader.execRoutine(async (ctx) => { + // // await errorHandler(props.caller, props.args, ctx); + // // }).catch((err) => { + // // console.warn('执行全局错误处理失败:', err); + // // }); + // // } + // // return props.args; + // // }); + // // appLoader.registerInternalErrorHandler(async (ctx, type, msg, err) => { + // // await errorHandler(ctx, type, msg, err); + // // }); + // } + appLoader.regAllExceptionHandler(); // 否则启动服务器模式 koa.use(async (ctx, next) => { try { diff --git a/lib/types/index.d.ts b/lib/types/index.d.ts index 7ab4e10..37d97a4 100644 --- a/lib/types/index.d.ts +++ b/lib/types/index.d.ts @@ -1,6 +1,6 @@ import { BaseEntityDict } from "oak-domain"; import { AsyncContext } from "oak-domain/lib/store/AsyncRowStore"; -import { EntityDict, OakException } from "oak-domain/lib/types"; +import { EntityDict } from "oak-domain/lib/types"; export type InternalErrorType = 'aspect' | 'trigger' | 'watcher' | 'timer' | 'checkpoint'; -export type InternalErrorHandler> = (ctx: Cxt, type: InternalErrorType, message: string, err: Error, oakException?: OakException) => Promise; +export type InternalErrorHandler> = (ctx: Cxt, type: InternalErrorType, message: string, err: Error) => Promise; export type ExceptionPublisher = (type: string, message: string, err: any) => Promise; diff --git a/src/server/start.ts b/src/server/start.ts index ed10cc0..b10a6b7 100644 --- a/src/server/start.ts +++ b/src/server/start.ts @@ -26,7 +26,6 @@ import chalk from 'chalk'; import { checkNodeVersion, randomString } from '../utils'; import bcrypt from 'bcryptjs'; import { LogFormatter, polyfillConsole, removePolyfill } from './polyfill'; -import { InternalErrorHandler } from '../types'; checkNodeVersion() @@ -57,18 +56,18 @@ export async function startup) => Promise, ): Promise<(() => Promise) | any> { - let errorHandler: InternalErrorHandler | undefined = undefined; + // let errorHandler: InternalErrorHandler | undefined = undefined; - try { - errorHandler = require(join( - path, - 'lib', - 'configuration', - 'exception' - )).default; - } catch (err) { - // 不存在exception配置 - } + // try { + // errorHandler = require(join( + // path, + // 'lib', + // 'configuration', + // 'exception' + // )).default; + // } catch (err) { + // // 不存在exception配置 + // } const serverConfiguration: ServerConfiguration = require(join( path, @@ -220,21 +219,22 @@ export async function startup { - // if (props.level === "error") { - // appLoader.execRoutine(async (ctx) => { - // await errorHandler(props.caller, props.args, ctx); - // }).catch((err) => { - // console.warn('执行全局错误处理失败:', err); - // }); - // } - // return props.args; - // }); - appLoader.registerInternalErrorHandler(async (ctx, type, msg, err, oakErr) => { - await errorHandler(ctx, type, msg, err, oakErr); - }); - } + // if (errorHandler && typeof errorHandler === 'function') { + // // polyfillConsole("startup", true, (props) => { + // // if (props.level === "error") { + // // appLoader.execRoutine(async (ctx) => { + // // await errorHandler(props.caller, props.args, ctx); + // // }).catch((err) => { + // // console.warn('执行全局错误处理失败:', err); + // // }); + // // } + // // return props.args; + // // }); + // // appLoader.registerInternalErrorHandler(async (ctx, type, msg, err) => { + // // await errorHandler(ctx, type, msg, err); + // // }); + // } + appLoader.regAllExceptionHandler() // 否则启动服务器模式 koa.use(async (ctx, next) => { diff --git a/src/types/index.ts b/src/types/index.ts deleted file mode 100644 index f51d2fc..0000000 --- a/src/types/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { BaseEntityDict } from "oak-domain"; -import { AsyncContext } from "oak-domain/lib/store/AsyncRowStore"; -import { EntityDict, OakException } from "oak-domain/lib/types"; - -export type InternalErrorType = 'aspect' | 'trigger' | 'watcher' | 'timer' | 'checkpoint' -export type InternalErrorHandler> = (ctx: Cxt, type: InternalErrorType, message:string, err: Error, oakException?: OakException, ) => Promise; -export type ExceptionPublisher = (type: string, message: string, err: any) => Promise; \ No newline at end of file