Enhances driver download error handling and logging across Dell and Lenovo driver tasks.

- Implements detailed failure tracking for driver downloads, capturing model names and statuses for failed attempts.
- Updates logging to provide clearer messages for both successful and failed downloads, improving traceability.
- Modifies the user interface to display comprehensive error messages when downloads fail, including a summary of failed models.
- Ensures that all exceptions during download and extraction processes are logged and thrown, preventing silent failures.
This commit is contained in:
rbalsleyMSFT
2025-10-30 18:26:05 -07:00
parent b4305a1edb
commit 4a10e27ddf
4 changed files with 145 additions and 105 deletions
@@ -716,6 +716,7 @@ function Invoke-DownloadSelectedDrivers {
$overallSuccess = $true
$successfullyDownloaded = [System.Collections.Generic.List[PSCustomObject]]::new()
$failedDownloads = [System.Collections.Generic.List[PSCustomObject]]::new()
# Check the results from the parallel processing tasks
if ($null -ne $parallelResults) {
@@ -737,11 +738,21 @@ function Invoke-DownloadSelectedDrivers {
if ([string]::IsNullOrWhiteSpace($modelName)) {
WriteLog "Could not determine model name from result object: $($result | ConvertTo-Json -Compress -Depth 3)"
$overallSuccess = $false
$failedDownloads.Add([PSCustomObject]@{
Model = 'Unknown model'
Status = 'Driver task returned without a model identifier.'
})
continue
}
if ($resultCode -ne 0) {
$overallSuccess = $false
$failureStatus = $result['Status']
if ([string]::IsNullOrWhiteSpace($failureStatus)) { $failureStatus = 'Driver download failed. Check the log for details.' }
$failedDownloads.Add([PSCustomObject]@{
Model = $modelName
Status = $failureStatus
})
WriteLog "Error detected for model $modelName."
}
elseif (-not [string]::IsNullOrWhiteSpace($driverPath)) {
@@ -758,6 +769,16 @@ function Invoke-DownloadSelectedDrivers {
WriteLog "Warning: Could not find 'Make' for successful download of model '$modelName'. Skipping from DriverMapping.json."
}
}
else {
$overallSuccess = $false
$fallbackStatus = $result['Status']
if ([string]::IsNullOrWhiteSpace($fallbackStatus)) { $fallbackStatus = 'Driver download did not return a driver path.' }
$failedDownloads.Add([PSCustomObject]@{
Model = $modelName
Status = $fallbackStatus
})
WriteLog "Driver download did not provide a path for model $modelName."
}
}
}
@@ -855,8 +876,21 @@ function Invoke-DownloadSelectedDrivers {
[System.Windows.MessageBox]::Show("All selected driver downloads processed. Check status column for details.", "Download Process Finished", "OK", "Information")
}
else {
$State.Controls.txtStatus.Text = "Driver downloads processed with some errors. Check status column and log."
[System.Windows.MessageBox]::Show("Driver downloads processed, but some errors occurred. Please check the status column for each driver and the log file for details.", "Download Process Finished with Errors", "OK", "Warning")
$State.Controls.txtStatus.Text = "Driver download failed. Resolve the errors and try again."
$messageLines = [System.Collections.Generic.List[string]]::new()
if ($failedDownloads.Count -gt 0) {
$messageLines.Add("Driver download failed for:")
foreach ($item in ($failedDownloads | Select-Object -First 5)) {
$messageLines.Add("- $($item.Model): $($item.Status)")
}
if ($failedDownloads.Count -gt 5) {
$messageLines.Add("...see the log for additional failures.")
}
}
else {
$messageLines.Add("One or more driver downloads failed. Check the log for details.")
}
[System.Windows.MessageBox]::Show(($messageLines -join [System.Environment]::NewLine), "Driver Download Failed", "OK", "Error")
}
}