From bb8214ae19b8af6641126befc0ab217def20c54c Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Wed, 1 Mar 2023 15:18:55 +0100 Subject: [PATCH 1/3] [examples] Add error handling of `LightingMgr().Init()` --- examples/lighting-app/linux/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/lighting-app/linux/main.cpp b/examples/lighting-app/linux/main.cpp index 0e51568049b327..121812cbac2495 100644 --- a/examples/lighting-app/linux/main.cpp +++ b/examples/lighting-app/linux/main.cpp @@ -89,7 +89,11 @@ int main(int argc, char * argv[]) return -1; } - LightingMgr().Init(); + if (LightingMgr().Init() != CHIP_NO_ERROR) + { + chip::DeviceLayer::PlatformMgr().Shutdown(); + return -1; + } #if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED example::Ui::ImguiUi ui; From 25916f40b15857ddf6177c18ba0e7984951a1795 Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Wed, 1 Mar 2023 17:56:40 +0100 Subject: [PATCH 2/3] Print out CHIP error message --- examples/lighting-app/linux/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/lighting-app/linux/main.cpp b/examples/lighting-app/linux/main.cpp index 121812cbac2495..987dbf102532e0 100644 --- a/examples/lighting-app/linux/main.cpp +++ b/examples/lighting-app/linux/main.cpp @@ -89,8 +89,10 @@ int main(int argc, char * argv[]) return -1; } - if (LightingMgr().Init() != CHIP_NO_ERROR) + CHIP_ERROR err = LightingMgr().Init(); + if (err != CHIP_NO_ERROR) { + ChipLogError(AppServer, "Failed to initialize lighting manager: %s", chip::ErrorStr(err)); chip::DeviceLayer::PlatformMgr().Shutdown(); return -1; } From 7fd1b96396a21df91e1461fa666777fe16d178ea Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Thu, 2 Mar 2023 09:30:15 +0100 Subject: [PATCH 3/3] Use preferred CHIP_ERROR_FORMAT --- examples/lighting-app/linux/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lighting-app/linux/main.cpp b/examples/lighting-app/linux/main.cpp index 987dbf102532e0..77fdc5911c90e6 100644 --- a/examples/lighting-app/linux/main.cpp +++ b/examples/lighting-app/linux/main.cpp @@ -92,7 +92,7 @@ int main(int argc, char * argv[]) CHIP_ERROR err = LightingMgr().Init(); if (err != CHIP_NO_ERROR) { - ChipLogError(AppServer, "Failed to initialize lighting manager: %s", chip::ErrorStr(err)); + ChipLogError(AppServer, "Failed to initialize lighting manager: %" CHIP_ERROR_FORMAT, err.Format()); chip::DeviceLayer::PlatformMgr().Shutdown(); return -1; }