Skip to content
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

Fixed handling of server responses with an error #303

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion JiraPS/Private/Resolve-ErrorWebResponse.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ function Resolve-ErrorWebResponse {

foreach ($_error in ($responseObject.errorMessages + $responseObject.errors)) {
# $_error is a PSCustomObject - therefore can't be $false
if (-not $_error.ToString()) { break }
if ($_error -is [PSCustomObject]) {
[String]$_error = ($_error | Out-String)
}
if (-not $_error) { throw "Unable to handle error" }

$writeErrorSplat = @{
Exception = $exception
Expand Down
8 changes: 4 additions & 4 deletions JiraPS/Public/Get-JiraIssueWatcher.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
Credential = $Credential
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

Write-Output $result.watchers
# TODO: are these users?
if ($result = Invoke-JiraMethod @parameter) {
Write-Output $result.watchers
# TODO: are these users?
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions JiraPS/Public/Get-JiraVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@
}

Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

$result | Where-Object {
$__ = $_.Name
Write-DebugMessage ($__ | Out-String)
$Name | Foreach-Object {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Matching $_ against $($__)"
$__ -like $_
if ($result = Invoke-JiraMethod @parameter) {
$result | Where-Object {
$__ = $_.Name
Write-DebugMessage ($__ | Out-String)
$Name | Foreach-Object {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Matching $_ against $($__)"
$__ -like $_
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions JiraPS/Public/Invoke-JiraMethod.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ function Invoke-JiraMethod {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] No Web result object was returned from. This is unusual!"
}
}

end {
Set-TlsLevel -Revert

Expand Down
12 changes: 6 additions & 6 deletions JiraPS/Public/New-JiraIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ function New-JiraIssue {
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
if ($PSCmdlet.ShouldProcess($Summary, "Creating new Issue on JIRA")) {
$result = Invoke-JiraMethod @parameter

# REST result will look something like this:
# {"id":"12345","key":"IT-3676","self":"http://jiraserver.example.com/rest/api/latest/issue/12345"}
# This will fetch the created issue to return it with all it'a properties
Write-Output (Get-JiraIssue -Key $result.Key -Credential $Credential)
if ($result = Invoke-JiraMethod @parameter) {
# REST result will look something like this:
# {"id":"12345","key":"IT-3676","self":"http://jiraserver.example.com/rest/api/latest/issue/12345"}
# This will fetch the created issue to return it with all it'a properties
Write-Output (Get-JiraIssue -Key $result.Key -Credential $Credential)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion JiraPS/Public/Remove-JiraGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function Remove-JiraGroupMember {
}

if ($PassThru) {
Write-Output (Get-JiraGroup -InputObject $g -Credential $Credential)
Write-Output (Get-JiraGroup -InputObject $groupObj -Credential $Credential)
}
}
}
Expand Down