Skip to content

Commit

Permalink
- Tighten up some of the exit code stuff in `Invoke-ADTWinGetDeployme…
Browse files Browse the repository at this point in the history
…ntOperation`.
  • Loading branch information
mjr4077au committed Dec 20, 2024
1 parent ca29c25 commit 1432fb2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ function Invoke-ADTWinGetDeploymentOperation
{
[System.Runtime.InteropServices.ExternalException]::new($wingetErrLine, $wingetPackageErrCode)
}
elseif ($Global:LASTEXITCODE)
elseif ($wingetPackageErrCode)
{
# All this bullshit is to change crap like '0x800704c7 : unknown error.' to 'Unknown error.'...
$wgErrorDef = if ([System.Enum]::IsDefined([ADTWinGetExitCode], $Global:LASTEXITCODE)) { [ADTWinGetExitCode]$Global:LASTEXITCODE }
$wgErrorDef = if ([System.Enum]::IsDefined([ADTWinGetExitCode], $wingetPackageErrCode)) { [ADTWinGetExitCode]$wingetPackageErrCode }
$wgErrorMsg = [System.Text.RegularExpressions.Regex]::Replace($wingetOutput[-1], '^0x\w{8}\s:\s(\w)', { $args[0].Groups[1].Value.ToUpper() })
[System.ComponentModel.Win32Exception]::new($Global:LASTEXITCODE, "WinGet operation finished with exit code 0x$($Global:LASTEXITCODE.ToString('X'))$(if ($wgErrorDef) {" ($wgErrorDef)"}) [$($wgErrorMsg.TrimEnd('.'))].")
[System.ComponentModel.Win32Exception]::new($wingetPackageErrCode, "WinGet operation finished with exit code 0x$($wingetPackageErrCode.ToString('X'))$(if ($wgErrorDef) {" ($wgErrorDef)"}) [$($wgErrorMsg.TrimEnd('.'))].")
}

# The WinGet cmdlets don't throw on install failure, but we need to within PSADT. Try
Expand Down

0 comments on commit 1432fb2

Please sign in to comment.