Skip to content

Commit

Permalink
Add try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
neilenns committed Jan 16, 2025
1 parent 624cd1e commit fc62bf7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions SimConnectMSFS/WasmModuleUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ private String ExtractCommunityFolderFromUserCfg(String UserCfg)
string CommunityFolder = null;
string line;
string InstalledPackagesPath = "";
StreamReader file = new StreamReader(UserCfg);
StreamReader file;

try
{
file = new StreamReader(UserCfg);
}
catch (Exception ex) {
Log.Instance.log($"Unable to open UserCfg.opt at {UserCfg}: {ex.Message}", LogSeverity.Error);
return CommunityFolder;
}

while ((line = file.ReadLine()) != null)
{
Expand All @@ -64,7 +73,7 @@ private String ExtractCommunityFolderFromUserCfg(String UserCfg)

InstalledPackagesPath = InstalledPackagesPath.Substring(23);
char[] charsToTrim = { '"' };

InstalledPackagesPath = InstalledPackagesPath.TrimEnd(charsToTrim);

string targetPath = Path.Combine(Path.Combine(InstalledPackagesPath, @"Community"));
Expand Down

0 comments on commit fc62bf7

Please sign in to comment.