mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-07-02 22:58:34 +00:00
fix(threading): surface runspace errors instead of swallowing them in GUI mode (#655)
This commit is contained in:
@@ -45,6 +45,15 @@ function Invoke-NonBlocking {
|
|||||||
|
|
||||||
$result = $ps.EndInvoke($handle)
|
$result = $ps.EndInvoke($handle)
|
||||||
|
|
||||||
|
# Surface non-terminating errors raised inside the runspace so GUI-mode operations
|
||||||
|
# (e.g. failed app removals) don't fail silently - the runspace keeps its own error
|
||||||
|
# stream that is otherwise discarded on Dispose.
|
||||||
|
if ($ps.HadErrors) {
|
||||||
|
foreach ($runspaceError in $ps.Streams.Error) {
|
||||||
|
Write-Error -ErrorRecord $runspaceError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($result.Count -eq 0) { return $null }
|
if ($result.Count -eq 0) { return $null }
|
||||||
if ($result.Count -eq 1) { return $result[0] }
|
if ($result.Count -eq 1) { return $result[0] }
|
||||||
return @($result)
|
return @($result)
|
||||||
|
|||||||
Reference in New Issue
Block a user