mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-07 08:52:59 +00:00
Print stack traces/add logging messages in several places
This will hopefully make it easier to track down various issues which might otherwise go unnoticed or provide little information. The main areas modified are those that external APIs may provide values for or interact with: various providers and ILuaObject/IPeripheral implementations. However, we do also log in a couple of other places which indicate a problem with this, or another, mod.
This commit is contained in:
@@ -11,6 +11,7 @@ import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.ILuaTask;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.core.apis.ILuaAPI;
|
||||
import dan200.computercraft.core.logger.Logger;
|
||||
import dan200.computercraft.shared.computer.blocks.TileCommandComputer;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -98,6 +99,7 @@ public class CommandAPI implements ILuaAPI
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
Logger.error( "Error running command.", t );
|
||||
return new Object[]{ false, createOutput( "Java Exception Thrown: " + t.toString() ) };
|
||||
}
|
||||
}
|
||||
@@ -208,6 +210,7 @@ public class CommandAPI implements ILuaAPI
|
||||
catch( Throwable t )
|
||||
{
|
||||
// Ignore buggy command
|
||||
Logger.error( "Error running command.", t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package dan200.computercraft.shared.network;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.core.logger.Logger;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
||||
@@ -24,7 +25,7 @@ public class PacketHandler
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
Logger.error( "Error handling packet", e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ public class PacketHandler
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
Logger.error( "Error handling packet", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package dan200.computercraft.shared.proxy;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.core.logger.Logger;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
@@ -83,7 +84,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
int id = upgrade.getLegacyUpgradeID();
|
||||
if( id >= 0 && id < 64 )
|
||||
{
|
||||
throw new RuntimeException( "Error registering '"+upgrade.getUnlocalisedAdjective()+" Turtle'. Legacy UpgradeID '"+id+"' is reserved by ComputerCraft" );
|
||||
throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. Legacy UpgradeID '" + id + "' is reserved by ComputerCraft" );
|
||||
}
|
||||
|
||||
// Register
|
||||
@@ -117,6 +118,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Logger.error("Error checking stackability of items", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -253,13 +255,13 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
{
|
||||
if( legacyID >= Short.MAX_VALUE )
|
||||
{
|
||||
throw new RuntimeException( "Error registering '"+upgrade.getUnlocalisedAdjective()+" Turtle'. UpgradeID '"+legacyID+"' is out of range" );
|
||||
throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is out of range" );
|
||||
}
|
||||
|
||||
ITurtleUpgrade existing = m_legacyTurtleUpgrades.get( legacyID );
|
||||
if( existing != null )
|
||||
{
|
||||
throw new RuntimeException( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" );
|
||||
throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +269,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
ITurtleUpgrade existing = m_turtleUpgrades.get( id );
|
||||
if( existing != null )
|
||||
{
|
||||
throw new RuntimeException( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + id + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" );
|
||||
throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + id + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" );
|
||||
}
|
||||
|
||||
// Register
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.core.logger.Logger;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class IDAssigner
|
||||
@@ -50,6 +52,7 @@ public class IDAssigner
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
Logger.error( "Unexpected file '" + content + "' in '" + location.getAbsolutePath() + "'", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +85,7 @@ public class IDAssigner
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
Logger.error( "Cannot open ID file '" + lastidFile + "'", e );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -92,7 +95,7 @@ public class IDAssigner
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
Logger.error( "Cannot parse ID file '" + lastidFile + "', perhaps it is corrupt?", e );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -107,8 +110,7 @@ public class IDAssigner
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
System.out.println( "An error occured while trying to create the computer folder. Please check you have relevant permissions." );
|
||||
e.printStackTrace();
|
||||
Logger.error( "An error occured while trying to create the computer folder. Please check you have relevant permissions.", e );
|
||||
}
|
||||
|
||||
return id;
|
||||
|
||||
Reference in New Issue
Block a user