fix: 处理require errors.js不存在的情况

This commit is contained in:
Pan Qiancheng 2025-10-16 11:18:42 +08:00
parent 8c642d79c2
commit df8426d102
2 changed files with 20 additions and 8 deletions

View File

@ -39,7 +39,13 @@ function concat(...paths) {
});
}
async function startup(path, connector, omitWatchers, omitTimers, routine) {
const errorHandler = require((0, path_1.join)(path, 'lib', 'configuration', 'errors')).default;
let errorHandler = undefined;
try {
errorHandler = require((0, path_1.join)(path, 'lib', 'configuration', 'errors')).default;
}
catch (err) {
// 不存在errors配置
}
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'));

View File

@ -57,12 +57,18 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
routine?: (context: AsyncContext<ED>) => Promise<void>,
): Promise<(() => Promise<any>) | any> {
const errorHandler: ErrorHandler<ED> = require(join(
let errorHandler: ErrorHandler<ED> | undefined = undefined;
try {
errorHandler = require(join(
path,
'lib',
'configuration',
'errors'
)).default;
} catch (err) {
// 不存在errors配置
}
const serverConfiguration: ServerConfiguration = require(join(
path,