From 7b6461170d3ce03b400ea975f75eac3a22479cba Mon Sep 17 00:00:00 2001 From: "gengchao4@huawei.com" Date: Thu, 31 Dec 2020 14:31:59 +0800 Subject: [PATCH] fix for json dump --- ge/analyzer/analyzer.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index 29181384..c63a6008 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -217,10 +217,15 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ json jsn; GraphInfoToJson(jsn, *graph_info); - json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; + bool ret_failed = false; + try { + json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; + } catch (nlohmann::detail::type_error &e) { + GELOGE(FAILED, "analyzer file [%s] failed because [%s]", json_file_name_.c_str(), e.what()); + ret_failed = true; + } json_file_.close(); - - return SUCCESS; + return ret_failed ? FAILED : SUCCESS; } ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {