From c85c344a9a1778e97379c8b616c264881c35c96c Mon Sep 17 00:00:00 2001 From: lidezhi Date: Tue, 9 Sep 2025 17:03:06 +0800 Subject: [PATCH] =?UTF-8?q?json=E4=B8=ADget=E6=8E=A5=E5=8F=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lidezhi Change-Id: Id7dffc96c0eaca7b00df140551107166407d398f --- services/context/src/widget_client.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/context/src/widget_client.cpp b/services/context/src/widget_client.cpp index 2a7431463..76c45d2d2 100644 --- a/services/context/src/widget_client.cpp +++ b/services/context/src/widget_client.cpp @@ -72,7 +72,13 @@ ResultCode WidgetClient::OnNotice(NoticeType type, const std::string &eventData) IAM_LOGE("OnNotice eventData is not json format"); return ResultCode::INVALID_PARAMETERS; } - WidgetNotice notice = root.get(); + WidgetNotice notice = {}; + try { + notice = root.get(); + } catch (const nlohmann::json::exception &e) { + IAM_LOGE("get WidgetNotice failed: %{public}s", e.what()); + return ResultCode::INVALID_PARAMETERS; + } if (notice.widgetContextId == 0) { IAM_LOGE("Invalid widget context id"); return ResultCode::INVALID_PARAMETERS; -- Gitee