Better Errors in GuiBridge.

This commit is contained in:
AlgorithmX2 2014-04-08 22:12:01 -05:00
parent 6203b172f6
commit 316822fe71

View file

@ -54,6 +54,7 @@ import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.ContainerVibrationChamber;
import appeng.container.implementations.ContainerWireless;
import appeng.container.implementations.ContainerWirelessTerm;
import appeng.core.AELog;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.helpers.WirelessTerminalGuiObject;
@ -197,7 +198,16 @@ public enum GuiBridge implements IGuiHandler
Constructor[] c = Container.getConstructors();
if ( c.length == 0 )
throw new AppEngException( "Invalid Gui Class" );
return findConstructor( c, inventory, tE ).newInstance( inventory, tE );
Constructor target = findConstructor( c, inventory, tE );
if ( target == null )
{
AELog.severe( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" );
return null;
}
return target.newInstance( inventory, tE );
}
catch (Throwable t)
{
@ -213,7 +223,15 @@ public enum GuiBridge implements IGuiHandler
if ( c.length == 0 )
throw new AppEngException( "Invalid Gui Class" );
return findConstructor( c, inventory, tE ).newInstance( inventory, tE );
Constructor target = findConstructor( c, inventory, tE );
if ( target == null )
{
AELog.severe( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + typeName( tE ) + " )" );
return null;
}
return target.newInstance( inventory, tE );
}
catch (Throwable t)
{
@ -221,6 +239,14 @@ public enum GuiBridge implements IGuiHandler
}
}
private String typeName(Object inventory)
{
if ( inventory == null )
return "NULL";
return inventory.getClass().getName();
}
private Constructor findConstructor(Constructor[] c, InventoryPlayer inventory, Object tE)
{
for (Constructor con : c)