Beautify code
MODIFY
WalletWasabi/Extensions/HttpResponseMessageExtensions.cs
WalletWasabi/Extensions/HttpResponseMessageExtensions.cs
@@ -82,9 +82,9 @@ namespace System.Net.Http
return startLine + headers + CRLF + messageBody;
}
- public async static Task ThrowRequestExceptionAsync<T>(this HttpResponseMessage me)
+ public async static Task ThrowRequestExceptionFromContentAsync(this HttpResponseMessage me)
{
- T error = await me.Content.ReadAsJsonAsync<T>();
+ var error = await me.Content.ReadAsJsonAsync<string>();
string errorMessage = error == null ? string.Empty : $"\n{error}";
throw new HttpRequestException($"{me.StatusCode.ToReasonString()}{errorMessage}");
}

MODIFY
WalletWasabi/WebClients/ChaumianCoinJoin/AliceClient.cs
WalletWasabi/WebClients/ChaumianCoinJoin/AliceClient.cs
@@ -36,7 +36,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
var inputsResponse = await response.Content.ReadAsJsonAsync<InputsResponse>();
@@ -80,7 +80,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
string roundHash = await response.Content.ReadAsJsonAsync<string>();
@@ -96,7 +96,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (!response.IsSuccessStatusCode)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
Logger.LogInfo<AliceClient>($"Round ({RoundId}), Alice ({UniqueId}): Unconfirmed connection.");
}
@@ -108,7 +108,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
var coinjoinHex = await response.Content.ReadAsJsonAsync<string>();
@@ -129,7 +129,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.NoContent)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
Logger.LogInfo<AliceClient>($"Round ({RoundId}), Alice ({UniqueId}): Posted {signatures.Count} signatures.");
}

MODIFY
WalletWasabi/WebClients/ChaumianCoinJoin/BobClient.cs
WalletWasabi/WebClients/ChaumianCoinJoin/BobClient.cs
@@ -23,7 +23,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.NoContent)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
}
}

MODIFY
WalletWasabi/WebClients/ChaumianCoinJoin/SatoshiClient.cs
WalletWasabi/WebClients/ChaumianCoinJoin/SatoshiClient.cs
@@ -25,7 +25,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
var states = await response.Content.ReadAsJsonAsync<IEnumerable<CcjRunningRoundState>>();

MODIFY
WalletWasabi/WebClients/ChaumianCoinJoin/WasabiClient.cs
WalletWasabi/WebClients/ChaumianCoinJoin/WasabiClient.cs
@@ -42,7 +42,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
}
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
using (HttpContent content = response.Content)
@@ -61,7 +61,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
using (HttpContent content = response.Content)
@@ -79,7 +79,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
}
}
@@ -104,7 +104,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode != HttpStatusCode.OK)
{
- await response.ThrowRequestExceptionAsync<string>();
+ await response.ThrowRequestExceptionFromContentAsync();
}
using (HttpContent content = response.Content)

Beautify code