Skip to content

Commit

Permalink
Throw exception for invalid packet type deserialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ijwu committed Aug 4, 2021
1 parent f592212 commit 7ace788
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
ArchipelagoPacketType packetType = (ArchipelagoPacketType)Enum.Parse(typeof(ArchipelagoPacketType), commandType);

ArchipelagoPacketBase ret = null;
ret = PacketDeserializationMap[packetType](token);
if (PacketDeserializationMap.ContainsKey(packetType))
{
ret = PacketDeserializationMap[packetType](token);
}
else
{
throw new InvalidOperationException("Received an unknown packet.");
}

return ret;
}
Expand Down

0 comments on commit 7ace788

Please sign in to comment.