Skip to content

Commit 53dcab7

Browse files
MuyuanMSCopilot
andcommitted
Address review: validate settings type and preserve exception details
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f39359b commit 53dcab7

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/common/SettingsAPI/settings_objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace PowerToysSettings
7878
{
7979
json::JsonObject prop_value;
8080
prop_value.SetNamedValue(L"value", json::value(value));
81-
if (!m_json.HasKey(L"properties"))
81+
if (!json::has(m_json, L"properties", json::JsonValueType::Object))
8282
{
8383
m_json.SetNamedValue(L"properties", json::JsonObject{});
8484
}

src/modules/LightSwitch/LightSwitchService/LightSwitchStateManager.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,17 @@ static std::pair<int, int> update_sun_times(auto& settings)
143143

144144
Logger::info(L"[LightSwitchService] Updated sun times and saved to config.");
145145
}
146+
catch (const winrt::hresult_error& e)
147+
{
148+
Logger::error(L"[LightSwitchService] Exception during sun time update: hresult_error 0x{:08X} - {}", e.code(), e.message().c_str());
149+
}
150+
catch (const std::exception& e)
151+
{
152+
Logger::error(L"[LightSwitchService] Exception during sun time update: std::exception - {}", winrt::to_hstring(e.what()).c_str());
153+
}
146154
catch (...)
147155
{
148-
Logger::error(L"[LightSwitchService] Exception during sun time update.");
156+
Logger::error(L"[LightSwitchService] Exception during sun time update: unknown exception");
149157
}
150158

151159
return { newLightTime, newDarkTime };

0 commit comments

Comments
 (0)