Skip to content

Commit

Permalink
Improve error message formatting and detail
Browse files Browse the repository at this point in the history
This commit refines the formatting for more streamlined error messages and increases the details provided when an error occurs. The detailed error message now includes instructions for the user to visit the Simple Launcher Wiki on Github for a list of parameters for each emulator.
  • Loading branch information
drpetersonfernandes committed Mar 26, 2024
1 parent 99c0222 commit 4213081
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions SimpleLauncher/GameLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ await process

if (process.ExitCode != 0 && process.ExitCode != -1073741819)
{
string errorMessage = $"Error launching external program:\n\nExit code {process.ExitCode}\n\n";
string errorMessage = $"Error launching external program\n\nExit code: {process.ExitCode}\n\n";
errorMessage += $"Emulator: {psi.FileName}\n\nArguments: {psi.Arguments}\n";
await LogErrors.LogErrorAsync(new Exception(errorMessage));
MessageBox.Show($"The emulator could not open this file.\n\n{errorMessage}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Expand All @@ -254,14 +254,15 @@ await process
}
catch (Exception ex)
{
string errorDetails = $"\nException Details: {ex}\n";
string errorDetails = $"Exception Details: {ex}\n";
if (psi != null)
{
errorDetails += $"\nEmulator: {psi.FileName}\n\nArguments: {psi.Arguments}\n";
errorDetails += $"\nEmulator: {psi.FileName}\n\nParameters: {psi.Arguments}\n";
}
await LogErrors.LogErrorAsync(ex, errorDetails);
// MessageBox.Show($"An error occurred: {ex.Message}\n{errorDetails}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show($"{ex.Message}\n{errorDetails}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
// MessageBox.Show($"{ex.Message}\n{errorDetails}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show($"Exception Details: {ex.Message}\n\nEmulator: {psi.FileName}\n\nParameters: {psi.Arguments}\n\nPlease visit the Simple Launcher Wiki on GitHub. There, you will find a list of parameters for each emulator.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}

Expand Down

0 comments on commit 4213081

Please sign in to comment.