Browse Source

Merge pull request #248 from ionite34/catch-install-errors

Catch & display install errors
pull/137/head
JT 1 year ago committed by GitHub
parent
commit
eaea3304d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs
  2. 7
      StabilityMatrix.Avalonia/ViewModels/Progress/PackageInstallProgressItemViewModel.cs
  3. 1
      StabilityMatrix.Core/Models/PackageModification/IPackageModificationRunner.cs
  4. 20
      StabilityMatrix.Core/Models/PackageModification/PackageModificationRunner.cs

4
StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs

@ -143,6 +143,9 @@ public partial class PackageManagerViewModel : PageViewModelBase
EventManager.Instance.OnPackageInstallProgressAdded(runner);
await runner.ExecuteSteps(steps.ToList());
if (!runner.Failed)
{
EventManager.Instance.OnInstalledPackagesChanged();
notificationService.Show(
"Package Install Complete",
@ -151,6 +154,7 @@ public partial class PackageManagerViewModel : PageViewModelBase
);
}
}
}
private IEnumerable<UnknownInstalledPackage> IndexUnknownPackages()
{

7
StabilityMatrix.Avalonia/ViewModels/Progress/PackageInstallProgressItemViewModel.cs

@ -42,6 +42,7 @@ public class PackageInstallProgressItemViewModel : ProgressItemViewModelBase
Progress.IsIndeterminate = e.IsIndeterminate;
Progress.Text = packageModificationRunner.CurrentStep?.ProgressTitle;
Name = packageModificationRunner.CurrentStep?.ProgressTitle;
Failed = packageModificationRunner.Failed;
if (string.IsNullOrWhiteSpace(e.Message) || e.Message.Contains("Downloading..."))
return;
@ -59,6 +60,12 @@ public class PackageInstallProgressItemViewModel : ProgressItemViewModelBase
{
Dispatcher.UIThread.Post(() => dialog?.Hide());
}
if (Failed)
{
Progress.Text = "Package Modification Failed";
Name = "Package Modification Failed";
}
}
public async Task ShowProgressDialog()

1
StabilityMatrix.Core/Models/PackageModification/IPackageModificationRunner.cs

@ -13,4 +13,5 @@ public interface IPackageModificationRunner
Guid Id { get; }
bool ShowDialogOnStart { get; init; }
string? ModificationCompleteMessage { get; init; }
bool Failed { get; set; }
}

20
StabilityMatrix.Core/Models/PackageModification/PackageModificationRunner.cs

@ -21,9 +21,27 @@ public class PackageModificationRunner : IPackageModificationRunner
foreach (var step in steps)
{
CurrentStep = step;
try
{
await step.ExecuteAsync(progress).ConfigureAwait(false);
}
catch (Exception e)
{
progress.Report(
new ProgressReport(
1f,
title: "Error modifying package",
message: $"Error: {e}",
isIndeterminate: false
)
);
Failed = true;
break;
}
}
if (!Failed)
{
progress.Report(
new ProgressReport(
1f,
@ -31,6 +49,7 @@ public class PackageModificationRunner : IPackageModificationRunner
isIndeterminate: false
)
);
}
IsRunning = false;
}
@ -39,6 +58,7 @@ public class PackageModificationRunner : IPackageModificationRunner
public bool ShowDialogOnStart { get; init; }
public bool IsRunning { get; set; }
public bool Failed { get; set; }
public ProgressReport CurrentProgress { get; set; }
public IPackageStep? CurrentStep { get; set; }
public List<string> ConsoleOutput { get; } = new();

Loading…
Cancel
Save