Merge pull request #2045 from yueh/fix-2044
Fixes #2044: No longer uses internal exceptions
This commit is contained in:
commit
71a9687b01
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.exceptions;
|
||||
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
|
||||
|
||||
/**
|
||||
* Exception occurred because of an already existing connection between the two {@link IGridNode}s
|
||||
*
|
||||
* Intended to signal an internal exception and not intended to be thrown by
|
||||
* any 3rd party module.
|
||||
*
|
||||
* @author yueh
|
||||
* @version rv3
|
||||
* @since rv3
|
||||
*/
|
||||
public class ExistingConnectionException extends FailedConnection
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 2975450379720353182L;
|
||||
private static final String DEFAULT_MESSAGE = "Connection between both nodes already exists.";
|
||||
|
||||
public ExistingConnectionException()
|
||||
{
|
||||
super( DEFAULT_MESSAGE );
|
||||
}
|
||||
|
||||
public ExistingConnectionException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
|
||||
}
|
|
@ -24,6 +24,22 @@
|
|||
package appeng.api.exceptions;
|
||||
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
|
||||
|
||||
/**
|
||||
* Exception indicating a failed connection between two {@link IGridNode}s.
|
||||
*
|
||||
* Intended to signal an internal exception and not intended to be thrown by
|
||||
* any 3rd party module.
|
||||
*
|
||||
* See any subclass for a more specific reason.
|
||||
*
|
||||
* @author AlgorithmX2
|
||||
* @author yueh
|
||||
* @version rv3
|
||||
* @since rv0
|
||||
*/
|
||||
public class FailedConnection extends Exception
|
||||
{
|
||||
|
||||
|
@ -32,4 +48,9 @@ public class FailedConnection extends Exception
|
|||
public FailedConnection()
|
||||
{
|
||||
}
|
||||
|
||||
public FailedConnection( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.exceptions;
|
||||
|
||||
|
||||
/**
|
||||
* Exception due to trying to connect one or more null values.
|
||||
*
|
||||
* Intended to signal an internal exception and not intended to be thrown by
|
||||
* any 3rd party module.
|
||||
*
|
||||
* @author yueh
|
||||
* @version rv3
|
||||
* @since rv3
|
||||
*/
|
||||
public class NullNodeConnectionException extends FailedConnection
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = -2143719383495321764L;
|
||||
private static final String DEFAULT_MESSAGE = "Connection forged between null entities.";
|
||||
|
||||
public NullNodeConnectionException()
|
||||
{
|
||||
super( DEFAULT_MESSAGE );
|
||||
}
|
||||
|
||||
public NullNodeConnectionException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.exceptions;
|
||||
|
||||
|
||||
/**
|
||||
* Exception due to trying to connect different security realms.
|
||||
*
|
||||
* Intended to signal an internal exception and not intended to be thrown by
|
||||
* any 3rd party module.
|
||||
*
|
||||
* @author yueh
|
||||
* @version rv3
|
||||
* @since rv3
|
||||
*/
|
||||
public class SecurityConnectionException extends FailedConnection
|
||||
{
|
||||
private static final long serialVersionUID = 5048714900434215426L;
|
||||
private static final String DEFAULT_MESSAGE = "Connection failed due to different security realms.";
|
||||
|
||||
public SecurityConnectionException()
|
||||
{
|
||||
super( DEFAULT_MESSAGE );
|
||||
}
|
||||
|
||||
public SecurityConnectionException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
|
||||
}
|
|
@ -24,7 +24,10 @@ import java.util.EnumSet;
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
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;
|
||||
|
@ -43,6 +46,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();
|
||||
private int channelData = 0;
|
||||
private Object visitorIterationNumber = null;
|
||||
|
@ -67,12 +72,12 @@ public class GridConnection implements IGridConnection, IPathItem
|
|||
AELog.info( "Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), b.getPlayerID() );
|
||||
}
|
||||
|
||||
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 ) )
|
||||
|
@ -82,7 +87,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;
|
||||
|
|
Loading…
Reference in New Issue