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:
@@ -62,7 +62,7 @@ public final class ConfigManager implements IConfigManager
|
||||
if( oldValue != null )
|
||||
return oldValue;
|
||||
|
||||
throw new RuntimeException( "Invalid Config setting" );
|
||||
throw new IllegalStateException( "Invalid Config setting. Expected a non-null value for " + settingName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -31,13 +32,11 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -951,7 +950,7 @@ public class Platform
|
||||
public static EntityPlayer getPlayer( WorldServer w )
|
||||
{
|
||||
if( w == null )
|
||||
throw new NullPointerException();
|
||||
throw new InvalidParameterException( "World is null." );
|
||||
|
||||
EntityPlayer wrp = FAKE_PLAYERS.get( w );
|
||||
if( wrp != null )
|
||||
@@ -1578,11 +1577,6 @@ public class Platform
|
||||
return !gs.hasPermission( playerID, SecurityPermissions.BUILD );
|
||||
}
|
||||
|
||||
public static boolean isDrawing( Tessellator tess )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void configurePlayer( EntityPlayer player, ForgeDirection side, TileEntity tile )
|
||||
{
|
||||
float pitch = 0.0f;
|
||||
|
||||
@@ -25,15 +25,15 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
|
||||
public class IMEAdaptorIterator implements Iterator<ItemSlot>
|
||||
public final class IMEAdaptorIterator implements Iterator<ItemSlot>
|
||||
{
|
||||
private final Iterator<IAEItemStack> stack;
|
||||
private final ItemSlot slot = new ItemSlot();
|
||||
private final IMEAdaptor parent;
|
||||
private final int containerSize;
|
||||
|
||||
final Iterator<IAEItemStack> stack;
|
||||
final ItemSlot slot = new ItemSlot();
|
||||
final IMEAdaptor parent;
|
||||
final int containerSize;
|
||||
int offset = 0;
|
||||
boolean hasNext;
|
||||
private int offset = 0;
|
||||
private boolean hasNext;
|
||||
|
||||
public IMEAdaptorIterator( IMEAdaptor parent, IItemList<IAEItemStack> availableItems )
|
||||
{
|
||||
@@ -73,6 +73,6 @@ public class IMEAdaptorIterator implements Iterator<ItemSlot>
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new RuntimeException( "Not Implemented!" );
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
@@ -60,15 +61,12 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
this.myHash = is.myHash;
|
||||
}
|
||||
|
||||
private AEFluidStack( FluidStack is )
|
||||
private AEFluidStack( @Nonnull FluidStack is )
|
||||
{
|
||||
if( is == null )
|
||||
throw new RuntimeException( "Invalid Itemstack." );
|
||||
|
||||
this.fluid = is.getFluid();
|
||||
|
||||
if( this.fluid == null )
|
||||
throw new RuntimeException( "Fluid is null." );
|
||||
throw new IllegalArgumentException( "Fluid is null." );
|
||||
|
||||
this.stackSize = is.amount;
|
||||
this.setCraftable( false );
|
||||
|
||||
@@ -79,7 +79,7 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
|
||||
return true;
|
||||
|
||||
if( !this.clz.isInstance( st ) )
|
||||
throw new RuntimeException( "WRONG TYPE - got " + st.getClass().getName() + " expected " + this.clz.getName() );
|
||||
throw new IllegalArgumentException( "WRONG TYPE - got " + st.getClass().getName() + " expected " + this.clz.getName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,37 +25,38 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
|
||||
|
||||
public class AEInvIterator implements Iterator<IAEItemStack>
|
||||
public final class AEInvIterator implements Iterator<IAEItemStack>
|
||||
{
|
||||
private final AppEngInternalAEInventory inventory;
|
||||
private final int size;
|
||||
|
||||
final AppEngInternalAEInventory inv;
|
||||
final int size;
|
||||
private int counter = 0;
|
||||
|
||||
int x = 0;
|
||||
|
||||
public AEInvIterator( AppEngInternalAEInventory i )
|
||||
public AEInvIterator( AppEngInternalAEInventory inventory )
|
||||
{
|
||||
this.inv = i;
|
||||
this.size = this.inv.getSizeInventory();
|
||||
this.inventory = inventory;
|
||||
this.size = this.inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return this.x < this.size;
|
||||
return this.counter < this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack next()
|
||||
{
|
||||
IAEItemStack result = this.inv.getAEStackInSlot( this.x );
|
||||
this.x++;
|
||||
final IAEItemStack result = this.inventory.getAEStackInSlot( this.counter );
|
||||
|
||||
this.counter++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new RuntimeException( "no..." );
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ package appeng.util.iterators;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
public class ChainedIterator<T> implements Iterator<T>
|
||||
public final class ChainedIterator<T> implements Iterator<T>
|
||||
{
|
||||
private final T[] list;
|
||||
|
||||
final T[] list;
|
||||
int offset = 0;
|
||||
private int offset = 0;
|
||||
|
||||
public ChainedIterator( T... list )
|
||||
{
|
||||
@@ -50,6 +50,6 @@ public class ChainedIterator<T> implements Iterator<T>
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new RuntimeException( "Not implemented." );
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,37 +25,37 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class InvIterator implements Iterator<ItemStack>
|
||||
public final class InvIterator implements Iterator<ItemStack>
|
||||
{
|
||||
private final IInventory inventory;
|
||||
private final int size;
|
||||
|
||||
final IInventory inv;
|
||||
final int size;
|
||||
private int counter = 0;
|
||||
|
||||
int x = 0;
|
||||
|
||||
public InvIterator( IInventory i )
|
||||
public InvIterator( IInventory inventory )
|
||||
{
|
||||
this.inv = i;
|
||||
this.size = this.inv.getSizeInventory();
|
||||
this.inventory = inventory;
|
||||
this.size = this.inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return this.x < this.size;
|
||||
return this.counter < this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack next()
|
||||
{
|
||||
ItemStack result = this.inv.getStackInSlot( this.x );
|
||||
this.x++;
|
||||
ItemStack result = this.inventory.getStackInSlot( this.counter );
|
||||
this.counter++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new RuntimeException( "no..." );
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,9 @@ import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
|
||||
|
||||
public class ProxyNodeIterator implements Iterator<IGridNode>
|
||||
public final class ProxyNodeIterator implements Iterator<IGridNode>
|
||||
{
|
||||
|
||||
final Iterator<IGridHost> hosts;
|
||||
private final Iterator<IGridHost> hosts;
|
||||
|
||||
public ProxyNodeIterator( Iterator<IGridHost> hosts )
|
||||
{
|
||||
@@ -53,6 +52,6 @@ public class ProxyNodeIterator implements Iterator<IGridNode>
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new RuntimeException( "Not implemented." );
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface IPartitionList<T extends IAEStack<T>>
|
||||
{
|
||||
|
||||
boolean isListed( T input );
|
||||
|
||||
boolean isEmpty();
|
||||
|
||||
@@ -20,16 +20,16 @@ package appeng.util.prioitylist;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
|
||||
public class MergedPriorityList<T extends IAEStack<T>> implements IPartitionList<T>
|
||||
public final class MergedPriorityList<T extends IAEStack<T>> implements IPartitionList<T>
|
||||
{
|
||||
|
||||
final List<IPartitionList<T>> positive = new ArrayList<IPartitionList<T>>();
|
||||
final List<IPartitionList<T>> negative = new ArrayList<IPartitionList<T>>();
|
||||
private final Collection<IPartitionList<T>> positive = new ArrayList<IPartitionList<T>>();
|
||||
private final Collection<IPartitionList<T>> negative = new ArrayList<IPartitionList<T>>();
|
||||
|
||||
public void addNewList( IPartitionList<T> list, boolean isWhitelist )
|
||||
{
|
||||
@@ -67,6 +67,6 @@ public class MergedPriorityList<T extends IAEStack<T>> implements IPartitionList
|
||||
@Override
|
||||
public Iterable<T> getItems()
|
||||
{
|
||||
throw new RuntimeException( "Not Implemented" );
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user