From a78909f78e0dbd173131e96507777a71ccf5b5f3 Mon Sep 17 00:00:00 2001 From: Arjun Gupta Date: Wed, 26 Feb 2020 11:38:04 +0530 Subject: [PATCH] fix write-exception --- .../Main.ps1 | 22 ++++++++++++++----- .../task.json | 2 +- .../task.loc.json | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Tasks/SqlDacpacDeploymentOnMachineGroupV0/Main.ps1 b/Tasks/SqlDacpacDeploymentOnMachineGroupV0/Main.ps1 index 7edff374e2be..eb49840d5d9b 100644 --- a/Tasks/SqlDacpacDeploymentOnMachineGroupV0/Main.ps1 +++ b/Tasks/SqlDacpacDeploymentOnMachineGroupV0/Main.ps1 @@ -7,15 +7,27 @@ function Write-Exception $exception ) - if($exception.Message) + $errorRecord = $PSItem + try { - Write-Error ($exception.Message) + if($exception.Message) + { + Write-Error ($exception.Message) + } + else + { + Write-Error ($exception) + } } - else + catch { - Write-Error ($exception) + if ($_ -ne $null) { + Write-Verbose "Write-Exception error:" + Write-Verbose $_.ToString() + } } - throw + + throw $errorRecord } function Get-SingleFile diff --git a/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.json b/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.json index c5df522f2223..9aab45d0ba3e 100644 --- a/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.json +++ b/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.json @@ -17,7 +17,7 @@ "version": { "Major": 0, "Minor": 3, - "Patch": 20 + "Patch": 21 }, "demands": [], "minimumAgentVersion": "1.102.0", diff --git a/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.loc.json b/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.loc.json index 18f2dc546c2b..6f0a774c2117 100644 --- a/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.loc.json +++ b/Tasks/SqlDacpacDeploymentOnMachineGroupV0/task.loc.json @@ -17,7 +17,7 @@ "version": { "Major": 0, "Minor": 3, - "Patch": 20 + "Patch": 21 }, "demands": [], "minimumAgentVersion": "1.102.0",