提交 44187725 编写于 作者: fxy060608's avatar fxy060608

chore: improve error log

上级 eb0f7615
......@@ -7,7 +7,7 @@
"platform": "platform",
"plugin": "plugin",
"performingHotReload": "Performing hot reload...",
"cliShared.parsingFailed": "Parsing failed",
"cliShared.parseJsonFailed": "Parsing failed",
"cliShared.doesNotExist": "does not exist",
"cliShared.pagesJsonError": "pages.json page configuration error, has been ignored, see {{0}}",
"cliShared.requireReturnJsonObject": "require return a json object",
......
......@@ -7,7 +7,7 @@
"platform": "平台",
"plugin": "插件",
"performingHotReload": "正在差量编译...",
"cliShared.parsingFailed": "解析失败",
"cliShared.parseJsonFailed": "解析失败,不符合 json 规范",
"cliShared.doesNotExist": "不存在",
"cliShared.pagesJsonError": "pages.json 页面配置错误,已被忽略,查看文档: {{0}}",
"cliShared.requireReturnJsonObject": "必须返回一个 json 对象",
......
......@@ -14,12 +14,7 @@ function parseJson (content, preprocess = false) {
type: jsPreprocessOptions.type
})
}
try {
content = JSON.parse(stripJsonComments(content))
} catch (e) {
throw new Error('uni-app-compiler: ' + e.message)
}
content = JSON.parse(stripJsonComments(content))
}
content = JSON.stringify(content)
......@@ -37,11 +32,11 @@ function getJson (jsonFileName, preprocess = false) {
try {
return parseJson(fs.readFileSync(jsonFilePath, 'utf8'), preprocess)
} catch (e) {
console.error(jsonFileName + uniI18n.__('cliShared.parsingFailed'))
throw new Error(jsonFileName + uniI18n.__('cliShared.parseJsonFailed') + '\n' + e.message)
}
}
module.exports = {
getJson,
parseJson
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册