Skip to content

Commit 6b94cc6

Browse files
committed
Guard deserialization error
1 parent a2479bf commit 6b94cc6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ElectronNET.API/API/Notification.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ private static void GenerateIDsForDefinedActions(NotificationOptions notificatio
9797
isActionDefined = true;
9898

9999
BridgeConnector.Socket.Off("NotificationEventAction");
100-
BridgeConnector.Socket.On<string[]>("NotificationEventAction", (args) => { _notificationOptions.Single(x => x.ActionID == args[0]).OnAction(args[1]); });
100+
BridgeConnector.Socket.On<string[]>("NotificationEventAction", (args) =>
101+
{
102+
var opt = _notificationOptions.Single(x => x.ActionID == args[0]);
103+
if (int.TryParse(args[1], out var index))
104+
{
105+
opt.OnAction(index);
106+
}
107+
});
101108
}
102109

103110
if (isActionDefined)

0 commit comments

Comments
 (0)