Skip to content
This repository was archived by the owner on Oct 25, 2022. It is now read-only.

Commit d09a94f

Browse files
authored
Merge pull request #183 from Thilas/updateall-errors
Display actual errors from jobs when any
2 parents f3ed598 + 867f93b commit d09a94f

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

AU/Public/Update-AUPackages.ps1

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,31 @@ function Update-AUPackages {
116116
else {
117117
Write-Verbose ($job.State + ' ' + $job.Name)
118118

119-
$pkg = $null
120-
Receive-Job $job | set pkg
121-
Remove-Job $job
122-
123-
$ignored = $pkg -eq 'ignore'
124-
if ( !$pkg -or $ignored ) {
125-
$pkg = [AUPackage]::new( (Get-AuPackages $($job.Name)) )
126-
127-
if ($ignored) {
128-
$pkg.Result = @('ignored', '') + (gc "$tmp_dir\$($pkg.Name)" -ea 0)
129-
$pkg.Ignored = $true
130-
$pkg.IgnoreMessage = $pkg.Result[-1]
131-
} elseif ($job.State -eq 'Stopped') {
132-
$pkg.Error = "Job terminated due to the $($Options.UpdateTimeout)s UpdateTimeout"
119+
if ($job.ChildJobs[0].JobStateInfo.Reason.Message) {
120+
$pkg = [AUPackage]::new((Get-AuPackages $job.Name))
121+
$pkg.Error = $job.ChildJobs[0].JobStateInfo.Reason.Message
122+
} else {
123+
$pkg = $null
124+
Receive-Job $job | set pkg
125+
126+
$ignored = $pkg -eq 'ignore'
127+
if ( !$pkg -or $ignored ) {
128+
$pkg = [AUPackage]::new( (Get-AuPackages $($job.Name)) )
129+
130+
if ($ignored) {
131+
$pkg.Result = @('ignored', '') + (gc "$tmp_dir\$($pkg.Name)" -ea 0)
132+
$pkg.Ignored = $true
133+
$pkg.IgnoreMessage = $pkg.Result[-1]
134+
} elseif ($job.State -eq 'Stopped') {
135+
$pkg.Error = "Job terminated due to the $($Options.UpdateTimeout)s UpdateTimeout"
136+
} else {
137+
$pkg.Error = 'Job returned no object, Vector smash ?'
138+
}
133139
} else {
134-
$pkg.Error = 'Job returned no object, Vector smash ?'
140+
$pkg = [AUPackage]::new($pkg)
135141
}
136-
} else {
137-
$pkg = [AUPackage]::new($pkg)
138142
}
143+
Remove-Job $job
139144

140145
$jobseconds = ($job.PSEndTime.TimeOfDay - $job.PSBeginTime.TimeOfDay).TotalSeconds
141146
$message = "[$($p)/$($aup.length)] " + $pkg.Name + ' '
@@ -196,7 +201,7 @@ function Update-AUPackages {
196201
break main
197202
}
198203
$type = if ($res) { $res.GetType() }
199-
if ( "$type" -eq 'AUPackage') { $res.Error = $_ } else { return $_ }
204+
if ( "$type" -eq 'AUPackage') { $res.Error = $_ } else { throw }
200205
}
201206
}
202207
$res

0 commit comments

Comments
 (0)