From f284173767869226e214313e14d2984738ff1558 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Thu, 22 Aug 2024 21:18:51 +0200 Subject: [PATCH] fix throw exception --- functions/public/Invoke-WPFUIElements.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index 6fcbd19c..2946f688 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -36,10 +36,8 @@ function Invoke-WPFUIElements { throw "Failed to retrieve Styles using 'FindResource' from main window element." } - try { - $targetGrid = $window.FindName($targetGridName) - } catch { - throw "Failed to find the target grid '$targetGridName' in the main window." + if (!$targetGrid) { + throw "Failed to retrieve Target Grid by name, provided name: $targetGrid" } # Clear existing ColumnDefinitions and Children