-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve sql azure deployment task errors handling #3263
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments shared
} | ||
catch [System.Exception] | ||
else | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If some Exception is raised here , We wont be returning result or exception trace in that case, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anything during execution of command fails it will come as part of result.
|
||
param( | ||
[string]$command, | ||
[bool] $failOnErr = $true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick - we can have verbose name like failOnError
@@ -722,6 +726,9 @@ function Parse-Exception($exception){ | |||
$responseBody = $streamReader.ReadToEnd() | |||
$streamReader.Close() | |||
Write-Verbose "Exception message extracted from response $responseBody" | |||
if($response.statusCode -eq 404){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do/Should We need to handle any othe rcase here like 500 etc ?
@@ -202,12 +202,12 @@ Catch [System.Management.Automation.CommandNotFoundException] | |||
Write-Host "3. Run Import-Module SQLPS on your agent Powershell prompt. (This step is not required on Powershell 3.0 enabled machines)" | |||
} | |||
|
|||
Write-Error ($_.Exception|Format-List -Force|Out-String) | |||
Write-Error ($_.Exception.Message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do like this - if exception.Message is not null and empty then write error.message but it is empty or null write full exception
@@ -664,7 +664,9 @@ function Add-AzureSqlDatabaseServerFirewallRule | |||
$parsedException = Parse-Exception($_.Exception) | |||
if($parsedException) | |||
{ | |||
throw $parsedException | |||
Write-Verbose $parsedException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be within Parse-Exception.
$ErrorActionPreference = 'Continue' | ||
if( $psversiontable.PSVersion.Major -le 4) | ||
{ | ||
$result = cmd.exe /c "`"$command`"" 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be using the task lib tool runner for this.
catch [System.Exception] | ||
else | ||
{ | ||
$result = cmd.exe /c "$command" 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Use task lib.
@@ -713,6 +713,7 @@ function Remove-AzureSqlDatabaseServerFirewallRule | |||
|
|||
function Parse-Exception($exception){ | |||
if($exception) { | |||
Write-Verbose "Exception message - $($exception.ToString())" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add L0 tests for validating various error scenarios
No description provided.