Fixes #2044: No longer uses internal exceptions

Added 3 new exception as subclass to FailedConnection to allow a more
precise handling and/or logging.
This commit is contained in:
yueh
2015-12-09 18:44:07 +01:00
parent daf2587140
commit 3a0eafce3c
5 changed files with 190 additions and 3 deletions
+8 -3
View File
@@ -22,7 +22,10 @@ package appeng.me;
import java.util.Arrays;
import java.util.EnumSet;
import appeng.api.exceptions.ExistingConnectionException;
import appeng.api.exceptions.FailedConnection;
import appeng.api.exceptions.NullNodeConnectionException;
import appeng.api.exceptions.SecurityConnectionException;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridNode;
@@ -42,6 +45,8 @@ import appeng.util.ReadOnlyCollection;
public class GridConnection implements IGridConnection, IPathItem
{
private static final String EXISTING_CONNECTION_MESSAGE = "Connection between node [machine=%s, %s] and [machine=%s, %s] on [%s] already exists.";
private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged();
public int channelData = 0;
Object visitorIterationNumber = null;
@@ -66,12 +71,12 @@ public class GridConnection implements IGridConnection, IPathItem
AELog.info( "Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), b.playerID );
}
throw new FailedConnection();
throw new SecurityConnectionException();
}
if( a == null || b == null )
{
throw new GridException( "Connection Forged Between null entities." );
throw new NullNodeConnectionException();
}
if( a.hasConnection( b ) || b.hasConnection( a ) )
@@ -81,7 +86,7 @@ public class GridConnection implements IGridConnection, IPathItem
final String aCoordinates = a.getGridBlock().getLocation().toString();
final String bCoordinates = b.getGridBlock().getLocation().toString();
throw new GridException( String.format( "Connection between node [machine=%s, %s] and [machine=%s, %s] on [%s] already exists.", aMachineClass, aCoordinates, bMachineClass, bCoordinates, fromAtoB ) );
throw new ExistingConnectionException( String.format( EXISTING_CONNECTION_MESSAGE, aMachineClass, aCoordinates, bMachineClass, bCoordinates, fromAtoB ) );
}
this.sideA = a;