Merge pull request #1299 from thatsIch/e-qol-exception-messages
Improved exceptions
This commit is contained in:
@@ -118,8 +118,9 @@ public final class Api implements IAppEngApi
|
||||
@Override
|
||||
public IGridNode createGridNode( IGridBlock blk )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
throw new RuntimeException( "Grid Features are Server Side Only." );
|
||||
if ( Platform.isClient() )
|
||||
throw new IllegalStateException( "Grid features for " + blk + " are server side only." );
|
||||
|
||||
return new GridNode( blk );
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class IMCHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException( "Invalid IMC Called: " + key );
|
||||
throw new IllegalStateException( "Invalid IMC Called: " + key );
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
|
||||
@@ -189,7 +189,7 @@ public final class Registration
|
||||
{
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
throw new IllegalStateException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
this.storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
|
||||
@@ -105,19 +105,19 @@ public class WorldSettings extends Configuration
|
||||
|
||||
if( !aeBaseFolder.isDirectory() && !aeBaseFolder.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
|
||||
throw new IllegalStateException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File compass = new File( aeBaseFolder, COMPASS_FOLDER );
|
||||
if( !compass.isDirectory() && !compass.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + compass.getAbsolutePath() );
|
||||
throw new IllegalStateException( "Failed to create " + compass.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File spawnData = new File( aeBaseFolder, SPAWNDATA_FOLDER );
|
||||
if( !spawnData.isDirectory() && !spawnData.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + spawnData.getAbsolutePath() );
|
||||
throw new IllegalStateException( "Failed to create " + spawnData.getAbsolutePath() );
|
||||
}
|
||||
|
||||
instance = new WorldSettings( aeBaseFolder );
|
||||
@@ -158,7 +158,7 @@ public class WorldSettings extends Configuration
|
||||
NBTTagCompound loadSpawnData( int dim, int chunkX, int chunkZ )
|
||||
{
|
||||
if( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
throw new IllegalStateException( "Invalid Request" );
|
||||
|
||||
NBTTagCompound data = null;
|
||||
File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" );
|
||||
@@ -225,7 +225,7 @@ public class WorldSettings extends Configuration
|
||||
void writeSpawnData( int dim, int chunkX, int chunkZ, NBTTagCompound data )
|
||||
{
|
||||
if( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
throw new IllegalStateException( "Invalid Request" );
|
||||
|
||||
File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" );
|
||||
FileOutputStream fileOutputStream = null;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
@@ -85,9 +86,9 @@ public class ApiPart implements IPartHelper
|
||||
{
|
||||
return Class.forName( base );
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( ClassNotFoundException e )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,14 +96,7 @@ public class ApiPart implements IPartHelper
|
||||
|
||||
if( this.tileImplementations.get( description ) != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.tileImplementations.get( description );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
return this.tileImplementations.get( description );
|
||||
}
|
||||
|
||||
String f = base;// TileCableBus.class.getName();
|
||||
@@ -121,9 +115,9 @@ public class ApiPart implements IPartHelper
|
||||
{
|
||||
myCLass = Class.forName( f );
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( ClassNotFoundException e )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
|
||||
String path = f;
|
||||
@@ -147,14 +141,7 @@ public class ApiPart implements IPartHelper
|
||||
|
||||
this.tileImplementations.put( description, myCLass );
|
||||
|
||||
try
|
||||
{
|
||||
return myCLass;
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
return myCLass;
|
||||
}
|
||||
|
||||
public Class getClassByDesc( String Addendum, String fullPath, String root, String next )
|
||||
@@ -247,19 +234,21 @@ public class ApiPart implements IPartHelper
|
||||
|
||||
public ClassNode getReader( String name )
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = '/' + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = this.getClass().getResourceAsStream( path );
|
||||
try
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = '/' + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = this.getClass().getResourceAsStream( path );
|
||||
cr = new ClassReader( is );
|
||||
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept( cn, ClassReader.EXPAND_FRAMES );
|
||||
|
||||
return cn;
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Error loading " + name, t );
|
||||
throw new IllegalStateException( "Error loading " + name, e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +295,7 @@ public class ApiPart implements IPartHelper
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
throw new RuntimeException( "Unable to manage part API.", e );
|
||||
throw new IllegalStateException( "Unable to manage part API.", e );
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DefinitionConstructor
|
||||
return ( (ITileDefinition) definition );
|
||||
}
|
||||
|
||||
throw new RuntimeException( "No tile definition" );
|
||||
throw new IllegalStateException( "No tile definition for " + feature );
|
||||
}
|
||||
|
||||
public final IBlockDefinition registerBlockDefinition( IAEFeature feature )
|
||||
@@ -52,7 +52,7 @@ public class DefinitionConstructor
|
||||
return ( (IBlockDefinition) definition );
|
||||
}
|
||||
|
||||
throw new RuntimeException( "No block definition" );
|
||||
throw new IllegalStateException( "No block definition for " + feature );
|
||||
}
|
||||
|
||||
public final IItemDefinition registerItemDefinition( IAEFeature feature )
|
||||
|
||||
@@ -77,10 +77,10 @@ public class IMCGrinder implements IIMCProcessor
|
||||
int turns = msg.getInteger( "turns" );
|
||||
|
||||
if( in == null )
|
||||
throw new RuntimeException( "invalid input" );
|
||||
throw new IllegalStateException( "invalid input" );
|
||||
|
||||
if( out == null )
|
||||
throw new RuntimeException( "invalid output" );
|
||||
throw new IllegalStateException( "invalid output" );
|
||||
|
||||
if( msg.hasKey( "optional" ) )
|
||||
{
|
||||
@@ -88,7 +88,7 @@ public class IMCGrinder implements IIMCProcessor
|
||||
ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag );
|
||||
|
||||
if( optional == null )
|
||||
throw new RuntimeException( "invalid optional" );
|
||||
throw new IllegalStateException( "invalid optional" );
|
||||
|
||||
float chance = msg.getFloat( "chance" );
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class IMCMatterCannon implements IIMCProcessor
|
||||
double weight = msg.getDouble( "weight" );
|
||||
|
||||
if( ammo == null )
|
||||
throw new RuntimeException( "invalid item" );
|
||||
throw new IllegalStateException( "invalid item in message " + m );
|
||||
|
||||
AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight );
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-item",
|
||||
package appeng.core.api.imc;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
@@ -55,9 +57,9 @@ public class IMCP2PAttunement implements IIMCProcessor
|
||||
if( is != null )
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type );
|
||||
else
|
||||
throw new RuntimeException( "invalid item" );
|
||||
throw new IllegalStateException( "invalid item in message " + m );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "invalid type" );
|
||||
throw new IllegalStateException( "invalid type in message " + m + " is not contained in " + Arrays.toString( TunnelType.values() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridCache;
|
||||
@@ -28,10 +30,9 @@ import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
public class GridCacheRegistry implements IGridCacheRegistry
|
||||
public final class GridCacheRegistry implements IGridCacheRegistry
|
||||
{
|
||||
|
||||
private final HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>>();
|
||||
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>>();
|
||||
|
||||
@Override
|
||||
public void registerGridCache( Class<? extends IGridCache> iface, Class<? extends IGridCache> implementation )
|
||||
@@ -39,7 +40,7 @@ public class GridCacheRegistry implements IGridCacheRegistry
|
||||
if( iface.isAssignableFrom( implementation ) )
|
||||
this.caches.put( iface, implementation );
|
||||
else
|
||||
throw new RuntimeException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements" );
|
||||
throw new IllegalArgumentException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + iface + " and " + implementation );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,15 +50,31 @@ public class GridCacheRegistry implements IGridCacheRegistry
|
||||
|
||||
for( Class<? extends IGridCache> iface : this.caches.keySet() )
|
||||
{
|
||||
Constructor<? extends IGridCache> c;
|
||||
try
|
||||
{
|
||||
Constructor<? extends IGridCache> c = this.caches.get( iface ).getConstructor( IGrid.class );
|
||||
c = this.caches.get( iface ).getConstructor( IGrid.class );
|
||||
map.put( iface, c.newInstance( g ) );
|
||||
}
|
||||
catch( Throwable e )
|
||||
catch( NoSuchMethodException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new RuntimeException( e );
|
||||
throw new IllegalArgumentException( e );
|
||||
}
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,9 @@ public class MovableTileRegistry implements IMovableRegistry
|
||||
@Override
|
||||
public void whiteListTileEntity( Class<? extends TileEntity> c )
|
||||
{
|
||||
|
||||
if( c.getName().equals( TileEntity.class.getName() ) )
|
||||
{
|
||||
throw new RuntimeException( new AppEngException( "Someone tried to make all tiles movable, this is a clear violation of the purpose of the white list." ) );
|
||||
throw new IllegalArgumentException( new AppEngException( "Someone tried to make all tiles movable with " + c + ", this is a clear violation of the purpose of the white list." ) );
|
||||
}
|
||||
|
||||
this.test.add( c );
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class AppEngPacket
|
||||
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
}
|
||||
|
||||
public final int getPacketID()
|
||||
@@ -50,7 +50,7 @@ public abstract class AppEngPacket
|
||||
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
}
|
||||
|
||||
protected void configureWrite( ByteBuf data )
|
||||
|
||||
@@ -130,7 +130,7 @@ public class AppEngPacketHandlerBase
|
||||
REVERSE_LOOKUP.put( this.packetClass, this );
|
||||
|
||||
if( this.packetConstructor == null )
|
||||
throw new RuntimeException( "Invalid Packet Class, must be constructable on DataInputStream" );
|
||||
throw new IllegalStateException( "Invalid Packet Class " + c + ", must be constructable on DataInputStream" );
|
||||
}
|
||||
|
||||
public static PacketTypes getPacket( int id )
|
||||
|
||||
@@ -228,10 +228,10 @@ public enum GuiBridge implements IGuiHandler
|
||||
String guiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" );
|
||||
|
||||
if( start.equals( guiClass ) )
|
||||
throw new RuntimeException( "Unable to find gui class" );
|
||||
throw new IllegalStateException( "Unable to find gui class" );
|
||||
this.Gui = ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass );
|
||||
if( this.Gui == null )
|
||||
throw new RuntimeException( "Cannot Load class: " + guiClass );
|
||||
throw new IllegalStateException( "Cannot Load class: " + guiClass );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ public enum GuiBridge implements IGuiHandler
|
||||
public boolean CorrectTileOrPart( Object tE )
|
||||
{
|
||||
if( this.Tile == null )
|
||||
throw new RuntimeException( "This Gui Cannot use the standard Handler." );
|
||||
throw new IllegalArgumentException( "This Gui Cannot use the standard Handler." );
|
||||
|
||||
return this.Tile.isInstance( tE );
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
throw new IllegalStateException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
Object o = target.newInstance( inventory, tE );
|
||||
@@ -364,7 +364,7 @@ public enum GuiBridge implements IGuiHandler
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,14 +462,14 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
throw new IllegalStateException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
return target.newInstance( inventory, tE );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
{
|
||||
|
||||
if( Platform.isClient() )
|
||||
throw new RuntimeException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
|
||||
Reference in New Issue
Block a user