main: Added error checking in new cold wallet creation

This commit is contained in:
Nathan Woodburn 2023-06-10 12:09:37 +10:00
parent 7388710704
commit 10662f5910
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -196,11 +196,11 @@ namespace FireWallet
this.Close();
}
else if (page == 4)
{
try
{
// Import Ledger
buttonNext.Enabled = false;
var proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardInput = true;
@ -225,7 +225,16 @@ namespace FireWallet
proc.WaitForExit();
mainForm.AddLog(outputBuilder.ToString());
}
catch (Exception ex)
{
mainForm.AddLog(ex.Message);
NotifyForm notify = new NotifyForm("Error importing wallet\n" + ex.Message);
notify.ShowDialog();
notify.Dispose();
this.Close();
return;
}
}
@ -248,21 +257,27 @@ namespace FireWallet
req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
req.Content = new StringContent(content);
try
{
// Send request
HttpResponseMessage resp = await httpClient.SendAsync(req);
try
if (resp.IsSuccessStatusCode)
{
resp.EnsureSuccessStatusCode();
return await resp.Content.ReadAsStringAsync();
} else
{
mainForm.AddLog("Put Error: " + await resp.Content.ReadAsStringAsync());
return "Error";
}
}
catch (Exception ex)
{
mainForm.AddLog("Put Error: " + ex.Message);
mainForm.AddLog(await resp.Content.ReadAsStringAsync());
return "Error";
}
return await resp.Content.ReadAsStringAsync();
}
}
}