fix exception antipattern
MODIFY
WalletWasabi/Hwi/HwiProcessManager.cs
WalletWasabi/Hwi/HwiProcessManager.cs
@@ -111,19 +111,13 @@ namespace WalletWasabi.Hwi
string response = await process.StandardOutput.ReadToEndAsync();
var jToken = JToken.Parse(response);
- string err = null;
- try
+ if (jToken is JObject json)
{
- JObject json = jToken as JObject;
- err = json.Value<string>("error");
- }
- catch (Exception ex)
+ if (json.TryGetValue("error", out JToken err))
{
- Logger.LogTrace(ex, nameof(HwiProcessManager));
+ var errString = err.ToString();
+ throw new IOException(errString);
}
- if (err != null)
- {
- throw new IOException(err);
}
return jToken;

fix exception antipattern