Skip to content

Commit

Permalink
Add try/catch for invalid PMDG input event values (#1014)
Browse files Browse the repository at this point in the history
Co-authored-by: Neil Enns <{ID}+{username}@users.noreply.github.com>
  • Loading branch information
neilenns and Neil Enns authored Dec 7, 2022
1 parent f8ab722 commit 3ac2366
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
17 changes: 12 additions & 5 deletions MobiFlight/ExecutionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,11 +1378,18 @@ void mobiFlightCache_OnButtonPressed(object sender, InputEventArgs e)
#if SIMCONNECT
Log.Instance.log($"{msgEventLabel} => executing \"{row["description"]}\"", LogSeverity.Info);

tuple.Item1.execute(
cacheCollection,
e,
GetRefs(tuple.Item1.ConfigRefs))
;
try
{
tuple.Item1.execute(
cacheCollection,
e,
GetRefs(tuple.Item1.ConfigRefs))
;
}
catch (Exception ex)
{
Log.Instance.log($"Error excuting \"{row["description"]}\": {ex.Message}", LogSeverity.Error);
}
#endif

}
Expand Down
9 changes: 8 additions & 1 deletion MobiFlight/InputConfig/PmdgEventIdInputAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ public override void execute(

value = Replace(value, replacements);

cacheCollection.fsuipcCache.setEventID(EventId, (int) UInt32.Parse(value));
try
{
cacheCollection.fsuipcCache.setEventID(EventId, (int)UInt32.Parse(value));
}
catch
{
Log.Instance.log($"Unable to convert eventId {EventId} value {value} to an integer.", LogSeverity.Error);
}
}

public override bool Equals(object obj)
Expand Down

0 comments on commit 3ac2366

Please sign in to comment.