Skip to content

Commit ab0feab

Browse files
committed
yet more exception stuff
1 parent aded64f commit ab0feab

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

FlashpointSecurePlayer/FlashpointSecurePlayerGUI.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private void ShowNoGameSelected() {
179179
try {
180180
processesByName = Process.GetProcessesByName(FLASHPOINT_LAUNCHER_PROCESS_NAME);
181181
} catch (InvalidOperationException ex) {
182-
// only occurs Windows XP which is unsupported
182+
// only occurs on Windows XP which is unsupported
183183
LogExceptionToLauncher(ex);
184184
ShowErrorFatal(Properties.Resources.WindowsVersionTooOld);
185185
return;
@@ -368,7 +368,9 @@ private void AskLaunchWithOldCPUSimulator() {
368368
throw new InvalidModificationException("The Modification failed to run with Old CPU Simulator.");
369369
}
370370

371-
private StringBuilder GetHTDOCSFilePath(Uri requestUri) {
371+
private async Task<StringBuilder> GetHTDOCSFilePath(string url) {
372+
Uri requestUri = await DownloadAsync(GetValidatedURL(url)).ConfigureAwait(true);
373+
372374
StringBuilder htdocsFilePath = new StringBuilder(HTDOCS);
373375

374376
try {
@@ -382,9 +384,9 @@ private StringBuilder GetHTDOCSFilePath(Uri requestUri) {
382384
htdocsFilePath.Append(requestUri.LocalPath);
383385
}
384386
} catch (UriFormatException) {
385-
throw new ArgumentException("The URL \"" + URL + "\" is malformed.");
387+
throw new ArgumentException("The URL \"" + url + "\" is malformed.");
386388
} catch (InvalidOperationException) {
387-
throw new ArgumentException("The URL \"" + URL + "\" is invalid.");
389+
throw new ArgumentException("The URL \"" + url + "\" is invalid.");
388390
}
389391
return htdocsFilePath;
390392
}
@@ -692,8 +694,8 @@ private void ActivateMode(TemplateElement templateElement, ErrorDelegate errorDe
692694
// StartProcessCreateBreakawayFromJob required for Process Sync on Windows 7
693695
StartProcessCreateBreakawayFromJob(softwareProcessStartInfo, out softwareProcess);
694696
} catch (JobObjectException ex) {
695-
LogExceptionToLauncher(ex);
696697
// popup message box and blow up
698+
LogExceptionToLauncher(ex);
697699
errorDelegate(Properties.Resources.JobObjectNotCreated);
698700
Environment.Exit(-1);
699701
throw new InvalidModeException("The Mode failed to create a Job Object.");
@@ -1166,9 +1168,10 @@ await ActivateModificationsAsync(templateElement, delegate (string text) {
11661168
LogExceptionToLauncher(ex);
11671169
return;
11681170
} catch (OldCPUSimulatorRequiresApplicationRestartException ex) {
1169-
LogExceptionToLauncher(ex);
11701171
// do this after all other modifications
11711172
// Old CPU Simulator can't handle restarts
1173+
LogExceptionToLauncher(ex);
1174+
11721175
try {
11731176
AskLaunchWithOldCPUSimulator();
11741177
} catch (InvalidModificationException ex2) {
@@ -1339,8 +1342,8 @@ private void FlashpointSecurePlayer_Load(object sender, EventArgs e) {
13391342

13401343
ModificationsRevertMethod = modificationsRevertMethod;
13411344
} catch (InvalidTemplateException ex) {
1342-
LogExceptionToLauncher(ex);
13431345
// catch on load
1346+
LogExceptionToLauncher(ex);
13441347
ShowNoGameSelected();
13451348
return;
13461349
} catch (TaskRequiresElevationException ex) {
@@ -1422,9 +1425,7 @@ await ImportActiveXAsync(delegate (string text) {
14221425

14231426
if (templateElement.Mode.Name == ModeElement.NAME.SOFTWARE) {
14241427
try {
1425-
Uri requestUri = await DownloadAsync(GetValidatedURL(URL)).ConfigureAwait(true);
1426-
1427-
string htdocsFilePath = GetHTDOCSFilePath(requestUri).ToString();
1428+
string htdocsFilePath = (await GetHTDOCSFilePath(URL)).ToString();
14281429

14291430
try {
14301431
htdocsFile = Path.GetFileName(htdocsFilePath);
@@ -1588,9 +1589,6 @@ private void webBrowserMode_FormClosing(object sender, FormClosingEventArgs e) {
15881589
// Set Current Directory
15891590
try {
15901591
Directory.SetCurrentDirectory(Application.StartupPath);
1591-
} catch (SecurityException ex) {
1592-
LogExceptionToLauncher(ex);
1593-
throw new TaskRequiresElevationException("Setting the Current Directory requires elevation.");
15941592
} catch {
15951593
// fail silently
15961594
}

0 commit comments

Comments
 (0)