Catch commands exception with ThrowException
MODIFY
WalletWasabi.Gui/Controls/LockScreen/PinLockScreenViewModel.cs
WalletWasabi.Gui/Controls/LockScreen/PinLockScreenViewModel.cs
@@ -5,6 +5,7 @@ using System.Reactive;
using ReactiveUI;
using System.Reactive.Disposables;
using System.Reactive.Linq;
+using WalletWasabi.Logging;
namespace WalletWasabi.Gui.Controls.LockScreen
{
@@ -62,6 +63,8 @@ namespace WalletWasabi.Gui.Controls.LockScreen
}
});
+ KeyPadCommand.ThrownExceptions.Subscribe(ex => Logger.LogError(ex));
+
this.WhenAnyValue(x => x.PinInput)
.Throttle(TimeSpan.FromSeconds(1))
.ObserveOn(RxApp.MainThreadScheduler)

MODIFY
WalletWasabi.Gui/Controls/MultiTextBox.cs
WalletWasabi.Gui/Controls/MultiTextBox.cs
@@ -91,6 +91,8 @@ namespace WalletWasabi.Gui.Controls
Disposables = new CompositeDisposable();
CopyToClipboardCommand = ReactiveCommand.CreateFromTask(async () => await TryCopyToClipboardAsync());
+
+ CopyToClipboardCommand.ThrownExceptions.Subscribe(ex => Logger.LogError(ex));
}
protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
@@ -162,10 +164,6 @@ namespace WalletWasabi.Gui.Controls
{
Logger.LogTrace(ex);
}
- catch (Exception ex)
- {
- Logger.LogWarning(ex);
- }
finally
{
CancelClipboardNotification?.Dispose();

MODIFY
WalletWasabi.Gui/Controls/QrCode.cs
WalletWasabi.Gui/Controls/QrCode.cs
@@ -39,9 +39,7 @@ namespace WalletWasabi.Gui.Controls
SaveCommand = ReactiveCommand.CreateFromTask<string, Unit>(SaveQRCodeAsync);
- SaveCommand.ThrownExceptions
- .ObserveOn(RxApp.TaskpoolScheduler)
- .Subscribe(ex => Logger.LogWarning(ex));
+ SaveCommand.ThrownExceptions.Subscribe(ex => Logger.LogError(ex));
}
public async Task<Unit> SaveQRCodeAsync(string address)

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -112,6 +112,15 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
TimeSpan left = x - DateTimeOffset.UtcNow;
TimeLeftTillRoundTimeout = left > TimeSpan.Zero ? left : TimeSpan.Zero; // Make sure cannot be less than zero.
});
+
+ Observable
+ .Merge(EnqueueCommand.ThrownExceptions)
+ .Merge(DequeueCommand.ThrownExceptions)
+ .Merge(PrivacySomeCommand.ThrownExceptions)
+ .Merge(PrivacyFineCommand.ThrownExceptions)
+ .Merge(PrivacyStrongCommand.ThrownExceptions)
+ .Merge(TargetButtonCommand.ThrownExceptions)
+ .Subscribe(ex => Logger.LogError(ex));
}
public override void OnOpen()

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
@@ -41,6 +41,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
});
SortCommand = ReactiveCommand.Create(RefreshOrdering);
+ SortCommand.ThrownExceptions.Subscribe(ex => Logger.LogError(ex));
DateSortDirection = SortOrder.Decreasing;

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/PinPadViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/PinPadViewModel.cs
@@ -50,9 +50,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
KeyPadCommand = ReactiveCommand.Create<string>((arg) => MaskedPin += arg);
- Observable.Merge(SendPinCommand.ThrownExceptions)
+ Observable
+ .Merge(SendPinCommand.ThrownExceptions)
.Merge(KeyPadCommand.ThrownExceptions)
- .Subscribe(OnException);
+ .Subscribe(ex => NotificationHelpers.Error(ex.ToTypeMessageString()));
}
public override void OnOpen()
@@ -70,11 +71,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return base.OnClose();
}
- private void OnException(Exception ex)
- {
- NotificationHelpers.Error(ex.ToTypeMessageString());
- }
-
public static async Task UnlockAsync(Global global)
{
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3));

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
@@ -149,8 +149,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
},
outputScheduler: RxApp.MainThreadScheduler);
- Observable.Merge(PasteCommand.ThrownExceptions)
+ Observable
+ .Merge(PasteCommand.ThrownExceptions)
.Merge(BroadcastTransactionCommand.ThrownExceptions)
+ .Merge(ImportTransactionCommand.ThrownExceptions)
.Subscribe(OnException);
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
@@ -67,20 +67,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public TransactionViewerViewModel(WalletViewModel walletViewModel) : base("Transaction", walletViewModel)
{
OpenTransactionBroadcaster = ReactiveCommand.Create(() =>
- {
- try
{
IoC.Get<IShell>().AddOrSelectDocument(() => new TransactionBroadcasterViewModel(Global));
- }
- catch (Exception ex)
- {
- NotificationHelpers.Error(ex.ToTypeMessageString());
- Logger.LogError(ex);
- }
});
ExportBinaryPsbt = ReactiveCommand.CreateFromTask(async () =>
- {
- try
{
var psbtExtension = "psbt";
var sfd = new SaveFileDialog
@@ -115,12 +105,15 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
await File.WriteAllBytesAsync(fileFullName, PsbtBytes);
}
- }
- catch (Exception ex)
+ });
+
+ Observable
+ .Merge(ExportBinaryPsbt.ThrownExceptions)
+ .Merge(OpenTransactionBroadcaster.ThrownExceptions)
+ .Subscribe(ex =>
{
- NotificationHelpers.Error(ex.ToTypeMessageString());
Logger.LogError(ex);
- }
+ NotificationHelpers.Error(ex.ToTypeMessageString());
});
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletAdvancedViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletAdvancedViewModel.cs
using ReactiveUI;
using System.Collections.ObjectModel;
using System.Reactive;
+using WalletWasabi.Gui.Helpers;
+using WalletWasabi.Logging;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -21,9 +23,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public WalletAdvancedViewModel(WalletViewModel walletViewModel) : base(walletViewModel.Name, walletViewModel)
{
Items = new ObservableCollection<WalletActionViewModel>();
-#pragma warning disable IDE0053 // Use expression body for lambda expressions
+
ExpandItCommand = ReactiveCommand.Create(() => { IsExpanded = !IsExpanded; });
-#pragma warning restore IDE0053 // Use expression body for lambda expressions
+
+ ExpandItCommand.ThrownExceptions.Subscribe(ex => Logger.LogError(ex));
}
public ObservableCollection<WalletActionViewModel> Items

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -31,8 +31,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
ClearSensitiveData(true);
ToggleSensitiveKeysCommand = ReactiveCommand.Create(() =>
- {
- try
{
if (ShowSensitiveKeys)
{
@@ -54,12 +52,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
string accountZ = secret.Derive(KeyManager.AccountKeyPath).ToZPrv(Global.Network);
SetSensitiveData(master, account, masterZ, accountZ);
}
- }
- catch (Exception ex)
- {
- NotificationHelpers.Error(ex.ToTypeMessageString());
- }
});
+
+ ToggleSensitiveKeysCommand.ThrownExceptions.Subscribe(ex => NotificationHelpers.Error(ex.ToTypeMessageString()));
}
private void ClearSensitiveData(bool passwordToo)

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
@@ -86,6 +86,8 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Global.UiConfig.LurkingWifeMode = !Global.UiConfig.LurkingWifeMode;
await Global.UiConfig.ToFileAsync();
});
+
+ LurkingWifeModeCommand.ThrownExceptions.Subscribe(ex => Logger.LogError(ex));
}
public void OnWalletOpened()

MODIFY
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
@@ -5,6 +5,7 @@ using System;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
+using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.TransactionOutputs;
@@ -80,8 +81,10 @@ namespace WalletWasabi.Gui.Dialogs
},
canCancel);
- OKCommand.ThrownExceptions.Subscribe(ex => Logger.LogWarning(ex));
- CancelCommand.ThrownExceptions.Subscribe(ex => Logger.LogWarning(ex));
+ Observable
+ .Merge(OKCommand.ThrownExceptions)
+ .Merge(CancelCommand.ThrownExceptions)
+ .Subscribe(ex => Logger.LogError(ex));
}
public override void OnOpen()

MODIFY
WalletWasabi.Gui/Dialogs/GenSocksServFailDialogViewModel.cs
WalletWasabi.Gui/Dialogs/GenSocksServFailDialogViewModel.cs
using AvalonStudio.Extensibility.Dialogs;
using ReactiveUI;
+using WalletWasabi.Logging;
+using System.Reactive.Linq;
namespace WalletWasabi.Gui.Dialogs
{
@@ -8,6 +10,7 @@ namespace WalletWasabi.Gui.Dialogs
public GenSocksServFailDialogViewModel() : base("", true, false)
{
OKCommand = ReactiveCommand.Create(() => Close(true)); // OK pressed.
+ OKCommand.ThrownExceptions.Subscribe(ex => Logger.LogError(ex));
}
}
}

Catch commands exception with ThrowException