Skip to content

Commit

Permalink
Change parameter validation to accommodate PSv3
Browse files Browse the repository at this point in the history
  • Loading branch information
hmmwhatsthisdo committed May 31, 2018
1 parent 157dcd4 commit 1627090
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions JiraPS/Public/Remove-JiraIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ function Remove-JiraIssue {
[ValidateScript(
{
if (("JiraPS.Issue" -notin $_.PSObject.TypeNames) -and (($_ -isnot [String]))) {
$errorItem = [System.Management.Automation.ErrorRecord]::new(
([System.ArgumentException]"Invalid Type for Parameter"),
'ParameterType.NotJiraIssue',
[System.Management.Automation.ErrorCategory]::InvalidArgument,
$_
)
$exception = ([System.ArgumentException]"Invalid Type for Parameter") #fix code highlighting]
$errorId = 'ParameterType.NotJiraIssue'
$errorCategory = 'InvalidArgument'
$errorTarget = $_
$errorItem = New-Object -TypeName "System.Management.Automation.ErrorRecord" -ArgumentList $exception,$errorId,$errorCategory,$errorTarget
$errorItem.ErrorDetails = "Wrong object type provided for Issue. Expected [JiraPS.Issue] or [String], but was $($_.GetType().Name)"
$PSCmdlet.ThrowTerminatingError($errorItem)
<#
Expand Down

0 comments on commit 1627090

Please sign in to comment.