-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Fixing Required Attachments #419
base: release/2.15-alpha
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,29 @@ function Resolve-ErrorWebResponse { | |
try { | ||
$responseObject = ConvertFrom-Json -InputObject $responseBody -ErrorAction Stop | ||
|
||
$errorArray = @() | ||
foreach ($_error in ($responseObject.errorMessages + $responseObject.errors)) { | ||
|
||
foreach ($_err in $_error.PSObject.Properties.Value) { | ||
if ($_err -like "*You must specify a summary of the issue." -Or $_err -like "*is required.") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't trust parsing text from the answer. What happens when the system is installed in another language? Is there any other way we can identify this? |
||
Write-Debug $_err | ||
$errorArray += $_err | ||
} else { | ||
# unhandled value | ||
} | ||
} | ||
|
||
if ($errorArray.count -gt 0) { | ||
$errorParameter = @{ | ||
ExceptionType = "System.Net.Http.HttpRequestException" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the same exception type as Invoke-WebRequest returns |
||
Message = "Missing Required Fields: $errorArray" | ||
ErrorId = "AuthenticationFailed" | ||
Category = "AuthenticationError" | ||
Cmdlet = $Cmdlet | ||
} | ||
ThrowError @errorParameter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't use |
||
} | ||
|
||
# $_error is a PSCustomObject - therefore can't be $false | ||
if ($_error -is [PSCustomObject]) { | ||
[String]$_error = ($_error | Out-String) | ||
|
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.
Please use
[System.Collections.ArrayList]
Reading material on why: https://gist.github.com/kevinblumenfeld/4a698dbc90272a336ed9367b11d91f1c