From 1282658153a8692a6ae6420ab0b26d7637d320c6 Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Wed, 22 Mar 2023 21:16:21 +0100 Subject: [PATCH] [examples] Add error handling of `LightingMgr().Init()` (#25398) * [examples] Add error handling of `LightingMgr().Init()` * Print out CHIP error message * Use preferred CHIP_ERROR_FORMAT --- examples/lighting-app/linux/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/lighting-app/linux/main.cpp b/examples/lighting-app/linux/main.cpp index 0e51568049b327..77fdc5911c90e6 100644 --- a/examples/lighting-app/linux/main.cpp +++ b/examples/lighting-app/linux/main.cpp @@ -89,7 +89,13 @@ int main(int argc, char * argv[]) return -1; } - LightingMgr().Init(); + CHIP_ERROR err = LightingMgr().Init(); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Failed to initialize lighting manager: %" CHIP_ERROR_FORMAT, err.Format()); + chip::DeviceLayer::PlatformMgr().Shutdown(); + return -1; + } #if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED example::Ui::ImguiUi ui;