Catch new exceptions.
MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -375,7 +375,7 @@ namespace WalletWasabi.Gui.ViewModels
catch (Exception ex)
{
Logger.LogError(ex);
- NotificationHelpers.Error($"Could not get Legal Documents!{(ex is TorConnectionException ? " Backend not connected. Check your internet connection!" : "")}");
+ NotificationHelpers.Error($"Could not get Legal Documents!{(ex.InnerException is TorConnectionException ? " Backend not connected. Check your internet connection!" : "")}");
}
finally
{

MODIFY
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
@@ -323,9 +323,9 @@ namespace WalletWasabi.Blockchain.Transactions
Logger.LogInfo($"Payjoin payment was negotiated successfully.");
}
- catch (TorConnectCommandFailedException e)
+ catch (HttpRequestException ex) when (ex.InnerException is TorConnectCommandFailedException innerEx)
{
- if (e.Message.Contains("HostUnreachable"))
+ if (innerEx.Message.Contains("HostUnreachable"))
{
Logger.LogWarning($"Payjoin server is not reachable. Ignoring...");
}

MODIFY
WalletWasabi/CoinJoin/Client/Clients/AliceClientBase.cs
WalletWasabi/CoinJoin/Client/Clients/AliceClientBase.cs
@@ -173,11 +173,11 @@ namespace WalletWasabi.CoinJoin.Client.Clients
{
return;
}
- catch (TorConnectionException) // If some internet connection issue then it'll likely time out and take it as unconfirmed.
+ catch (HttpRequestException ex) when (ex.InnerException is TorConnectionException) // If some Internet connection issue then it'll likely time out and take it as unconfirmed.
{
return;
}
- catch (TorConnectCommandFailedException) // If some Tor connection issue then it'll likely time out and take it as unconfirmed.
+ catch (HttpRequestException ex) when (ex.InnerException is TorConnectCommandFailedException) // If some Tor connection issue then it'll likely time out and take it as unconfirmed.
{
return;
}

MODIFY
WalletWasabi/Services/WasabiSynchronizer.cs
WalletWasabi/Services/WasabiSynchronizer.cs
@@ -187,18 +187,18 @@ namespace WalletWasabi.Services
TorStatus = TorStatus.Running;
DoNotGenSocksServFail();
}
- catch (TorConnectionException ex)
+ catch (HttpRequestException ex) when (ex.InnerException is TorConnectionException innerEx)
{
TorStatus = TorStatus.NotRunning;
BackendStatus = BackendStatus.NotConnected;
- HandleIfGenSocksServFail(ex);
+ HandleIfGenSocksServFail(innerEx);
throw;
}
- catch (TorConnectCommandFailedException ex)
+ catch (HttpRequestException ex) when (ex.InnerException is TorConnectCommandFailedException innerEx)
{
TorStatus = TorStatus.Running;
BackendStatus = BackendStatus.NotConnected;
- HandleIfGenSocksServFail(ex);
+ HandleIfGenSocksServFail(innerEx);
throw;
}
catch (HttpRequestException ex) when (ex.Message.Contains("Not Found"))

MODIFY
WalletWasabi/Tor/Http/TorHttpClient.cs
WalletWasabi/Tor/Http/TorHttpClient.cs
@@ -73,9 +73,8 @@ namespace WalletWasabi.Tor.Http
return new ClearnetHttpClient(DestinationUriAction).SendAsync(request, isolateStream, cancellationToken);
}
- /// <remarks>
- /// Throws <see cref="OperationCanceledException"/> if <paramref name="cancel"/> is set.
- /// </remarks>
+ /// <exception cref="HttpRequestException">When HTTP request fails to be processed. Inner exception may be an instance of <see cref="TorException"/>.</exception>
+ /// <exception cref="OperationCanceledException">When <paramref name="cancel"/> is canceled by the user.</exception>
public async Task<HttpResponseMessage> SendAsync(HttpMethod method, string relativeUri, HttpContent? content = null, CancellationToken cancel = default)
{
Guard.NotNull(nameof(method), method);
@@ -160,6 +159,13 @@ namespace WalletWasabi.Tor.Http
SetTorNotWorkingState(ex);
throw;
}
+ catch (TorException ex)
+ {
+ SetTorNotWorkingState(ex);
+
+ // Wrap exception to unify ClearnetHttpClient and TorHttpClient exception throwing behavior.
+ throw new HttpRequestException("Failed to handle the HTTP request via Tor.", inner: ex);
+ }
catch (Exception ex)
{
SetTorNotWorkingState(ex);

Catch new exceptions.

Signed-off-by: Kiminuo <kiminuo@protonmail.com>