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

chore: improve error log

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