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
8cf88ab0e4
5 changed files with 33 additions and 12 deletions
|
|
@ -19,6 +19,11 @@ namespace RHLauncher.RHLauncher.Helper
|
|||
string md5 = CalculateMD5(service);
|
||||
|
||||
string serviceDatPath = Path.Combine(_installDirectory, "Service.dat");
|
||||
|
||||
try
|
||||
{
|
||||
if (File.Exists(serviceDatPath))
|
||||
{
|
||||
string[] lines = File.ReadAllLines(serviceDatPath);
|
||||
|
||||
string currentMd5 = lines[0];
|
||||
|
|
@ -30,6 +35,17 @@ namespace RHLauncher.RHLauncher.Helper
|
|||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -145,6 +145,11 @@ namespace RHLauncher
|
|||
LaunchButton.Click -= LaunchGameButton_Click;
|
||||
LaunchButton.Click += LaunchGameButton_Click;
|
||||
break;
|
||||
case UpdateState.Error:
|
||||
LaunchButton.Text = LocalizedStrings.Launch;
|
||||
LaunchButton.Click -= LaunchGameButton_Click;
|
||||
LaunchButton.Click += LaunchGameButton_Click;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace RHLauncher
|
|||
private async Task<string> SendEmailRequestAsync()
|
||||
{
|
||||
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),
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ namespace RHLauncher
|
|||
private async Task<string> VerifyCodeSendRequestAsync()
|
||||
{
|
||||
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>("verification_code", CodeTextBox.Text),
|
||||
|
|
@ -113,7 +113,7 @@ namespace RHLauncher
|
|||
private async Task<string> SendRequestAsync()
|
||||
{
|
||||
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>("email", EmailTextBox.Text),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<AssemblyName>Launcher</AssemblyName>
|
||||
<Description>Rusty Hearts Launcher</Description>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
||||
<AssemblyVersion>1.0.1</AssemblyVersion>
|
||||
<FileVersion>1.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace RHLauncher
|
|||
try
|
||||
{
|
||||
using HttpClient client = new();
|
||||
HttpResponseMessage response = await client.GetAsync(LauncherVersionUrl);
|
||||
using HttpResponseMessage response = await client.GetAsync(LauncherVersionUrl);
|
||||
response.EnsureSuccessStatusCode();
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
dynamic result = JsonConvert.DeserializeObject(json);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue