mirror of
https://github.com/JuniorDark/RustyHearts-Launcher.git
synced 2026-05-07 05:21:44 -04:00
Add more error handling
This commit is contained in:
parent
7917f223e1
commit
71f7609dc5
4 changed files with 32 additions and 11 deletions
|
|
@ -19,6 +19,11 @@ namespace RHLauncher.RHLauncher.Helper
|
||||||
string md5 = CalculateMD5(service);
|
string md5 = CalculateMD5(service);
|
||||||
|
|
||||||
string serviceDatPath = Path.Combine(_installDirectory, "Service.dat");
|
string serviceDatPath = Path.Combine(_installDirectory, "Service.dat");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(serviceDatPath))
|
||||||
|
{
|
||||||
string[] lines = File.ReadAllLines(serviceDatPath);
|
string[] lines = File.ReadAllLines(serviceDatPath);
|
||||||
|
|
||||||
string currentMd5 = lines[0];
|
string currentMd5 = lines[0];
|
||||||
|
|
@ -30,6 +35,17 @@ namespace RHLauncher.RHLauncher.Helper
|
||||||
File.WriteAllLines(serviceDatPath, lines);
|
File.WriteAllLines(serviceDatPath, lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MsgBoxForm.Show("Service.dat file does not exist. Please check if the Install Directory is correct.", LocalizedStrings.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MsgBoxForm.Show("An error occurred while updating service: " + ex.Message, LocalizedStrings.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string CalculateMD5(string input)
|
private static string CalculateMD5(string input)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,11 @@ namespace RHLauncher
|
||||||
LaunchButton.Click -= LaunchGameButton_Click;
|
LaunchButton.Click -= LaunchGameButton_Click;
|
||||||
LaunchButton.Click += LaunchGameButton_Click;
|
LaunchButton.Click += LaunchGameButton_Click;
|
||||||
break;
|
break;
|
||||||
|
case UpdateState.Error:
|
||||||
|
LaunchButton.Text = LocalizedStrings.Launch;
|
||||||
|
LaunchButton.Click -= LaunchGameButton_Click;
|
||||||
|
LaunchButton.Click += LaunchGameButton_Click;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace RHLauncher
|
||||||
private async Task<string> SendEmailRequestAsync()
|
private async Task<string> SendEmailRequestAsync()
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.PostAsync(SendCodeUrl, new FormUrlEncodedContent(new[]
|
using HttpResponseMessage response = await client.PostAsync(SendCodeUrl, new FormUrlEncodedContent(new[]
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace RHLauncher
|
||||||
private async Task<string> VerifyCodeSendRequestAsync()
|
private async Task<string> VerifyCodeSendRequestAsync()
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(new[]
|
using HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(new[]
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||||
new KeyValuePair<string, string>("verification_code", CodeTextBox.Text),
|
new KeyValuePair<string, string>("verification_code", CodeTextBox.Text),
|
||||||
|
|
@ -113,7 +113,7 @@ namespace RHLauncher
|
||||||
private async Task<string> SendRequestAsync()
|
private async Task<string> SendRequestAsync()
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.PostAsync(RegisterUrl, new FormUrlEncodedContent(new[]
|
using HttpResponseMessage response = await client.PostAsync(RegisterUrl, new FormUrlEncodedContent(new[]
|
||||||
{
|
{
|
||||||
new KeyValuePair<string, string>("windyCode", NameTextBox.Text),
|
new KeyValuePair<string, string>("windyCode", NameTextBox.Text),
|
||||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace RHLauncher
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using HttpClient client = new();
|
using HttpClient client = new();
|
||||||
HttpResponseMessage response = await client.GetAsync(LauncherVersionUrl);
|
using HttpResponseMessage response = await client.GetAsync(LauncherVersionUrl);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
string json = await response.Content.ReadAsStringAsync();
|
string json = await response.Content.ReadAsStringAsync();
|
||||||
dynamic result = JsonConvert.DeserializeObject(json);
|
dynamic result = JsonConvert.DeserializeObject(json);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue