From 1c2b30161340e8671f9d24af6f47fc798c91fcb8 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Tue, 20 Aug 2024 21:32:16 +0200 Subject: [PATCH] add error handling for styles --- functions/public/Invoke-WPFUIElements.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index 18066e6a..cb276662 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -31,6 +31,10 @@ function Invoke-WPFUIElements { $borderstyle = $window.FindResource("BorderStyle") $HoverTextBlockStyle = $window.FindResource("HoverTextBlockStyle") $ColorfulToggleSwitchStyle = $window.FindResource("ColorfulToggleSwitchStyle") + + if (!$borderstyle -or !$HoverTextBlockStyle -or !$ColorfulToggleSwitchStyle) { + throw "Failed to retrieve Styles using 'FindResource' from main window element." + } $targetGrid = $window.FindName($targetGridName)