From 9ac8a0b597ac0c9417fb2e6ff52f15553afe64ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Dallidet?= Date: Fri, 18 Oct 2024 16:50:29 +0200 Subject: [PATCH] Fixes #25708: Windows techniques fail to catch the Nustache.Core.RaiseExceptionOnEmptyStringValue errors --- .../rudderc/templates/technique.ps1.askama | 3 +- .../cases/general/escaping/technique.ps1 | 6 ++-- .../tests/cases/general/form/technique.ps1 | 3 +- .../long_method_param_name/technique.ps1 | 3 +- .../tests/cases/general/min/technique.ps1 | 3 +- .../tests/cases/general/ntp/technique.ps1 | 6 ++-- .../general/param_in_condition/technique.ps1 | 6 ++-- .../cases/general/policy_mode/technique.ps1 | 36 +++++++------------ .../cases/general/reporting/technique.ps1 | 30 ++++++---------- .../cases/general/variables/technique.ps1 | 3 +- 10 files changed, 33 insertions(+), 66 deletions(-) diff --git a/policies/rudderc/templates/technique.ps1.askama b/policies/rudderc/templates/technique.ps1.askama index e645c94d5a2..5425a655652 100644 --- a/policies/rudderc/templates/technique.ps1.askama +++ b/policies/rudderc/templates/technique.ps1.askama @@ -69,7 +69,7 @@ function {{ id|technique_name }} { {%- else %} Rudder-Report-NA @reportParams {%- endif %} - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -80,7 +80,6 @@ function {{ id|technique_name }} { Compute-Method-Call @fallBackReportParams -PolicyMode {{ m.policy_mode_override|policy_mode_fmt }} -ReportId $reportId -DisableReporting:${{ m.disable_reporting }} -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/escaping/technique.ps1 b/policies/rudderc/tests/cases/general/escaping/technique.ps1 index 82f896dcfce..f44f2b1c739 100644 --- a/policies/rudderc/tests/cases/general/escaping/technique.ps1 +++ b/policies/rudderc/tests/cases/general/escaping/technique.ps1 @@ -95,7 +95,7 @@ if(Get-Service "Zabbix agent") { write-output "exists" } } else { Rudder-Report-NA @reportParams } - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -106,7 +106,6 @@ if(Get-Service "Zabbix agent") { write-output "exists" } Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -174,7 +173,7 @@ if(Get-Service "Zabbix agent") { write-output "exists" } $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -185,7 +184,6 @@ if(Get-Service "Zabbix agent") { write-output "exists" } Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/form/technique.ps1 b/policies/rudderc/tests/cases/general/form/technique.ps1 index cc82ce44983..4af16689d96 100644 --- a/policies/rudderc/tests/cases/general/form/technique.ps1 +++ b/policies/rudderc/tests/cases/general/form/technique.ps1 @@ -95,7 +95,7 @@ htop } else { Rudder-Report-NA @reportParams } - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -106,7 +106,6 @@ htop Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/long_method_param_name/technique.ps1 b/policies/rudderc/tests/cases/general/long_method_param_name/technique.ps1 index 9a2d2b4668b..ac6aa35546f 100644 --- a/policies/rudderc/tests/cases/general/long_method_param_name/technique.ps1 +++ b/policies/rudderc/tests/cases/general/long_method_param_name/technique.ps1 @@ -35,7 +35,7 @@ TechniqueName = $techniqueName } Rudder-Report-NA @reportParams - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -46,7 +46,6 @@ Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/min/technique.ps1 b/policies/rudderc/tests/cases/general/min/technique.ps1 index bdad1b1fa47..05de30a1375 100644 --- a/policies/rudderc/tests/cases/general/min/technique.ps1 +++ b/policies/rudderc/tests/cases/general/min/technique.ps1 @@ -49,7 +49,7 @@ htop $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -60,7 +60,6 @@ htop Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/ntp/technique.ps1 b/policies/rudderc/tests/cases/general/ntp/technique.ps1 index 393fcc4b4b3..b830d42b106 100644 --- a/policies/rudderc/tests/cases/general/ntp/technique.ps1 +++ b/policies/rudderc/tests/cases/general/ntp/technique.ps1 @@ -58,7 +58,7 @@ htop } else { Rudder-Report-NA @reportParams } - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -69,7 +69,6 @@ htop Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -115,7 +114,7 @@ vars.node.inventory.os.fullName } else { Rudder-Report-NA @reportParams } - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -126,7 +125,6 @@ vars.node.inventory.os.fullName Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/param_in_condition/technique.ps1 b/policies/rudderc/tests/cases/general/param_in_condition/technique.ps1 index 3e2a5e05661..aad0b733f8b 100644 --- a/policies/rudderc/tests/cases/general/param_in_condition/technique.ps1 +++ b/policies/rudderc/tests/cases/general/param_in_condition/technique.ps1 @@ -42,7 +42,7 @@ vars.param_in_condition.file TechniqueName = $techniqueName } Rudder-Report-NA @reportParams - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -53,7 +53,6 @@ vars.param_in_condition.file Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -95,7 +94,7 @@ echo "May be executed or not" } else { Rudder-Report-NA @reportParams } - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -106,7 +105,6 @@ echo "May be executed or not" Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/policy_mode/technique.ps1 b/policies/rudderc/tests/cases/general/policy_mode/technique.ps1 index d4c36d0aa6d..44e86728177 100644 --- a/policies/rudderc/tests/cases/general/policy_mode/technique.ps1 +++ b/policies/rudderc/tests/cases/general/policy_mode/technique.ps1 @@ -50,7 +50,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Audit) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -61,7 +61,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -99,7 +98,7 @@ foobar $call = File-Content @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -110,7 +109,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -148,7 +146,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Enforce) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -159,7 +157,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -197,7 +194,7 @@ foobar $call = File-Content @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -208,7 +205,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -246,7 +242,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Audit) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -257,7 +253,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -295,7 +290,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Enforce) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -306,7 +301,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -344,7 +338,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Audit) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -355,7 +349,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -393,7 +386,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Audit) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -404,7 +397,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -442,7 +434,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Enforce) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -453,7 +445,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -491,7 +482,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Enforce) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -502,7 +493,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -540,7 +530,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Audit) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -551,7 +541,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Audit) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -589,7 +578,7 @@ foobar $call = File-Content @methodParams -PolicyMode ([Rudder.PolicyMode]::Enforce) Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -600,7 +589,6 @@ foobar Compute-Method-Call @fallBackReportParams -PolicyMode ([Rudder.PolicyMode]::Enforce) -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/reporting/technique.ps1 b/policies/rudderc/tests/cases/general/reporting/technique.ps1 index 37ce3f2ac57..ffbcd9a3a07 100644 --- a/policies/rudderc/tests/cases/general/reporting/technique.ps1 +++ b/policies/rudderc/tests/cases/general/reporting/technique.ps1 @@ -49,7 +49,7 @@ htop $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -60,7 +60,6 @@ htop Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -101,7 +100,7 @@ htop } else { Rudder-Report-NA @reportParams } - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -112,7 +111,6 @@ htop Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -149,7 +147,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -160,7 +158,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -197,7 +194,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -208,7 +205,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -245,7 +241,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -256,7 +252,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -293,7 +288,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -304,7 +299,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -341,7 +335,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -352,7 +346,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -389,7 +382,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -400,7 +393,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$true -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -437,7 +429,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -448,7 +440,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] @@ -485,7 +476,7 @@ ntp $call = Package-Present @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -496,7 +487,6 @@ ntp Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$true -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1] diff --git a/policies/rudderc/tests/cases/general/variables/technique.ps1 b/policies/rudderc/tests/cases/general/variables/technique.ps1 index 247053bb5f9..2547310b07d 100644 --- a/policies/rudderc/tests/cases/general/variables/technique.ps1 +++ b/policies/rudderc/tests/cases/general/variables/technique.ps1 @@ -76,7 +76,7 @@ vars.node.properties.name.key $call = File-Content @methodParams -PolicyMode $policyMode Compute-Method-Call @reportParams -MethodCall $call - } catch [Nustache.Core.NustacheDataContextMissException] { + } catch [Nustache.Core.NustacheDataContextMissException], [Nustache.Core.NustacheException] { $failedCall = [Rudder.MethodResult]::Error( ([String]::Format( 'The method call was skipped because it references an undefined variable "{0}"', @@ -87,7 +87,6 @@ vars.node.properties.name.key Compute-Method-Call @fallBackReportParams -PolicyMode $policyMode -ReportId $reportId -DisableReporting:$false -MethodCall $failedCall } catch { $failedCall = [Rudder.MethodResult]::Error( - [Rudder.MethodStatus]::Error, ([String]::Format( 'The method call was skipped as an unexpected error was thrown "{0}"', (Format-Exception $_)[1]