完善错误处理
This commit is contained in:
parent
a51dac512c
commit
4f15fe79d0
|
|
@ -235,5 +235,5 @@
|
|||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
"version": "2.0.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,6 +138,19 @@ function anaEntitiesUsingDomain(): EntityDict {
|
|||
const pHome = pathConfig.projectHome;
|
||||
const cwd = process.cwd();
|
||||
try {
|
||||
// 先判断${pHome}/node_modules/oak-domain/lib/compiler/schemalBuilder.js是否存在
|
||||
const schemaFilePath = path.join(
|
||||
pHome,
|
||||
'node_modules',
|
||||
'oak-domain',
|
||||
'lib',
|
||||
'compiler',
|
||||
'schemalBuilder.js'
|
||||
);
|
||||
if (!fs.existsSync(schemaFilePath)) {
|
||||
throw new Error('oak-domain未安装或版本不匹配');
|
||||
}
|
||||
// 这里需要设置一下当前目录,防止找不到模块
|
||||
process.chdir(pHome);
|
||||
const { analyzeEntities, getAnalizedSchema, translateLocaleObject, constructAttributes, getProjectionKeys } =
|
||||
require(`${pHome}/node_modules/oak-domain/lib/compiler/schemalBuilder`);
|
||||
|
|
@ -251,14 +264,11 @@ export const analyzeOakAppDomain = async (
|
|||
setLoadingEntities(true);
|
||||
isAnalyzing = true;
|
||||
try {
|
||||
|
||||
const newEntityDict = anaEntitiesUsingDomain();
|
||||
|
||||
// 更新 entityDictCache
|
||||
Object.keys(newEntityDict).forEach((key) => {
|
||||
entityDictCache[key] = newEntityDict[key];
|
||||
});
|
||||
|
||||
if (enableCache) {
|
||||
// 写入缓存
|
||||
fs.writeFile(
|
||||
|
|
@ -276,8 +286,8 @@ export const analyzeOakAppDomain = async (
|
|||
} catch (error) {
|
||||
console.log('分析过程中发生错误:', error);
|
||||
// 删除缓存的目录,便于下一次分析
|
||||
vscode.window.showErrorMessage(`分析过程中发生错误`);
|
||||
fs.unlinkSync(pathConfig.cachePath);
|
||||
vscode.window.showErrorMessage(`分析过程中发生错误: ${(error as Error).message}`);
|
||||
fs.unlinkSync(cacheFile);
|
||||
} finally {
|
||||
isAnalyzing = false;
|
||||
setLoadingEntities(false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue