1From 30f4729ea2c01e1ed437ba92a81e2fc098d608a9 Mon Sep 17 00:00:00 2001 2From: shenwei41 <shenwei41@huawei.com> 3Date: Wed, 17 May 2023 18:35:10 +0800 4Subject: [PATCH] Fix UpdateArray json parse error 5 6--- 7 mindspore/ccsrc/minddata/dataset/util/json_helper.cc | 11 ++++++++--- 8 1 file changed, 8 insertions(+), 3 deletions(-) 9 10diff --git a/mindspore/ccsrc/minddata/dataset/util/json_helper.cc b/mindspore/ccsrc/minddata/dataset/util/json_helper.cc 11index e3572487e94..22c400dc3ea 100644 12--- a/mindspore/ccsrc/minddata/dataset/util/json_helper.cc 13+++ b/mindspore/ccsrc/minddata/dataset/util/json_helper.cc 14@@ -82,7 +82,6 @@ Status JsonHelper::UpdateArray(const std::string &in_file, const std::string &ke 15 in_stream.close(); 16 } 17 js[key] = value; 18- MS_LOG(INFO) << "Write outfile is: " << js << "."; 19 if (out_file == "") { 20 std::ofstream o(in_file, std::ofstream::trunc); 21 o << js; 22@@ -94,8 +93,14 @@ Status JsonHelper::UpdateArray(const std::string &in_file, const std::string &ke 23 } 24 } 25 // Catch any exception and convert to Status return code 26- catch (const std::exception &err) { 27- RETURN_STATUS_UNEXPECTED("Update json failed "); 28+ catch (nlohmann::json::exception &e) { 29+ std::string err_msg = "Parse json failed. Error info: "; 30+ err_msg += e.what(); 31+ RETURN_STATUS_UNEXPECTED(err_msg); 32+ } catch (const std::exception &e) { 33+ std::string err_msg = "Update json failed. Error info: "; 34+ err_msg += e.what(); 35+ RETURN_STATUS_UNEXPECTED(err_msg); 36 } 37 return Status::OK(); 38 } 39-- 40Gitee 41