protect wallet loading with try catch, and clear isbusy in case of exceptions.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ClosedWalletViewModel.cs
using AvalonStudio.Extensibility;
using ReactiveUI;
using Splat;
+using System;
using System.IO;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Threading;
+using WalletWasabi.Gui.Helpers;
+using WalletWasabi.Logging;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -14,6 +17,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public ClosedWalletViewModel(string path) : base(Path.GetFileNameWithoutExtension(path))
{
OpenWalletCommand = ReactiveCommand.CreateFromTask(async () =>
+ {
+ try
{
IsBusy = true;
@@ -30,11 +35,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (keyManager is null)
{
- IsBusy = false;
return;
}
- var walletService = await walletManager.CreateAndStartWalletAsync(keyManager);
+ var wallet = await walletManager.CreateAndStartWalletAsync(keyManager);
var walletExplorer = IoC.Get<WalletExplorerViewModel>();
@@ -42,17 +46,25 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
walletExplorer.RemoveWallet(this);
- if (walletService.Coins.Any())
+ if (wallet.Coins.Any())
{
// If already have coins then open the last active tab first.
- walletExplorer.OpenWallet(walletService, receiveDominant: false, select: select);
+ walletExplorer.OpenWallet(wallet, receiveDominant: false, select: select);
}
else // Else open with Receive tab first.
{
- walletExplorer.OpenWallet(walletService, receiveDominant: true, select: select);
+ walletExplorer.OpenWallet(wallet, receiveDominant: true, select: select);
}
-
+ }
+ catch (Exception e)
+ {
+ NotificationHelpers.Error($"Error loading Wallet: {Title}");
+ Logger.LogError(e.Message);
+ }
+ finally
+ {
IsBusy = false;
+ }
}, this.WhenAnyValue(x => x.IsBusy).Select(x => !x));
}

protect wallet loading with try catch, and clear isbusy in case of exceptions.