mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Merge pull request #355 from jk-5/errorhandling
Throw an exception when discriminator is not found
This commit is contained in:
commit
608d401b75
1 file changed
+4
@@ -46,6 +46,10 @@ public abstract class FMLIndexedMessageToMessageCodec<A> extends MessageToMessag
|
||||
ByteBuf payload = msg.payload();
|
||||
byte discriminator = payload.readByte();
|
||||
Class<? extends A> clazz = discriminators.get(discriminator);
|
||||
if(clazz == null)
|
||||
{
|
||||
throw new NullPointerException("Undefined message for discriminator " + discriminator + " in channel " + msg.channel());
|
||||
}
|
||||
A newMsg = clazz.newInstance();
|
||||
decodeInto(ctx, payload.slice(), newMsg);
|
||||
out.add(newMsg);
|
||||
|
||||
Reference in new issue
Block a user