Improved exceptions
Many exceptions got an improvement due to changed class or description or details it is providing. Is not complete, needs to be done in patches in the regions, where it is needed, since some are just swallowed. Removed total usage of pure RuntimeExceptions to 0.
This commit is contained in:
@@ -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() ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user