Add exception hadling and xml tag.
MODIFY
WalletWasabi/Hwi/HwiProcessManager.cs
WalletWasabi/Hwi/HwiProcessManager.cs
@@ -127,10 +127,14 @@ namespace WalletWasabi.Hwi
/// <param name="cancellationToken">Cancel the current operation.</param>
/// <param name="command">Command to send in string format.</param>
/// <param name="isMutexPriority">You can add priority to your command among hwi calls. For example if multiply wasabi instances are running both use the same hwi process with isMutexPriority you will more likely to get it.</param>
- /// <returns></returns>
+ /// <returns>JToken the answer recevied from hwi process.</returns>
+ /// <exception cref="TimeoutException">Thrown when the process cannot be finished in time.</exception>
+ /// <exception cref="IOException">Thrown when Mutex on hwi process could not be acquired.</exception>
public static async Task<JToken> SendCommandAsync(string command, CancellationToken cancellationToken, bool isMutexPriority = false)
{
- using (await AsyncLock.LockAsync(cancellationToken))
+ try
+ {
+ using (await AsyncLock.LockAsync())
using (var mutex = new Mutex(false, MutexName)) // It could be even improved more if this Mutex would also look at which hardware wallet the operation is going towards (enumerate sends to all.)
{
var mutexAcquired = false;
@@ -246,6 +250,11 @@ namespace WalletWasabi.Hwi
}
}
}
+ catch (Exception ex) when (ex is OperationCanceledException || ex is TaskCanceledException || ex is TimeoutException)
+ {
+ throw new TimeoutException("Timeout occured during the hwi operation.", ex);
+ }
+ }
public static async Task InitializeAsync(string dataDir, Network network, bool logFound = true)
{

Add exception hadling and xml tag.