1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

Add config option to disable certain error messages

This commit is contained in:
SquidDev 2017-05-16 15:59:09 +01:00
parent a0b6cbb671
commit efb0065ebd
6 changed files with 25 additions and 6 deletions

View File

@ -107,6 +107,7 @@ public class ComputerCraft
public static String http_whitelist = "*";
public static boolean disable_lua51_features = false;
public static String default_computer_settings = "";
public static boolean logPeripheralErrors = true;
public static boolean enableCommandBlock = false;
public static boolean turtlesNeedFuel = true;
@ -180,6 +181,7 @@ public static class Config {
public static Property http_whitelist;
public static Property disable_lua51_features;
public static Property default_computer_settings;
public static Property logPeripheralErrors;
public static Property enableCommandBlock;
public static Property turtlesNeedFuel;
@ -253,6 +255,10 @@ public void preInit( FMLPreInitializationEvent event )
Config.default_computer_settings = Config.config.get( Configuration.CATEGORY_GENERAL, "default_computer_settings", default_computer_settings );
Config.default_computer_settings.setComment( "A comma seperated list of default system settings to set on new computers. Example: \"shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false\" will disable all autocompletion" );
Config.logPeripheralErrors = Config.config.get( Configuration.CATEGORY_GENERAL, "logPeripheralErrors", logPeripheralErrors );
Config.logPeripheralErrors.setComment( "Log exceptions thrown by peripherals and other Lua objects.\n" +
"This makes it easier for mod authors to debug problems, but may result in log spam should people use buggy methods." );
Config.enableCommandBlock = Config.config.get( Configuration.CATEGORY_GENERAL, "enableCommandBlock", enableCommandBlock );
Config.enableCommandBlock.setComment( "Enable Command Block peripheral support" );

View File

@ -140,7 +140,7 @@ public void run() {
// Step 3: abandon
if( worker.isAlive() )
{
ComputerCraft.log.warn( "Failed to abort Computer " + computer.getID() + ". Dangling lua thread could cause errors." );
// ComputerCraft.log.warn( "Failed to abort Computer " + computer.getID() + ". Dangling lua thread could cause errors." );
worker.interrupt();
}
}

View File

@ -415,7 +415,10 @@ public void execute()
}
catch( Throwable t )
{
ComputerCraft.log.error( "Error running task", t);
if( ComputerCraft.logPeripheralErrors )
{
ComputerCraft.log.error( "Error running task", t );
}
m_computer.queueEvent( "task_complete", new Object[] {
taskID, false, "Java Exception Thrown: " + t.toString()
} );
@ -482,7 +485,10 @@ public Object[] executeMainThreadTask( @Nonnull final ILuaTask task ) throws Lua
}
catch( Throwable t )
{
ComputerCraft.log.error( "Error calling " + methodName + " on " + apiObject, t );
if( ComputerCraft.logPeripheralErrors )
{
ComputerCraft.log.error( "Error calling " + methodName + " on " + apiObject, t );
}
throw new LuaError( "Java Exception Thrown: " + t.toString(), 0 );
}
return LuaValue.varargsOf( toValues( results, 0 ) );

View File

@ -99,7 +99,10 @@ private Object[] doCommand( String command )
}
catch( Throwable t )
{
ComputerCraft.log.error( "Error running command.", t );
if( ComputerCraft.logPeripheralErrors )
{
ComputerCraft.log.error( "Error running command.", t );
}
return new Object[]{ false, createOutput( "Java Exception Thrown: " + t.toString() ) };
}
}
@ -210,7 +213,10 @@ public Object[] execute() throws LuaException
catch( Throwable t )
{
// Ignore buggy command
ComputerCraft.log.error( "Error running command.", t );
if( ComputerCraft.logPeripheralErrors )
{
ComputerCraft.log.error( "Error running command.", t );
}
}
}
}

View File

@ -119,7 +119,7 @@ public ITurtleUpgrade getTurtleUpgrade( ItemStack stack )
}
catch( Exception e )
{
ComputerCraft.log.error("Error checking stackability of items", e);
ComputerCraft.log.error("Error getting computer upgrade item", e);
}
}
return null;

View File

@ -44,6 +44,7 @@ gui.computercraft:config.http_enable=Enable HTTP API
gui.computercraft:config.http_whitelist=HTTP whitelist
gui.computercraft:config.disable_lua51_features=Disable Lua 5.1 features
gui.computercraft:config.default_computer_settings=Default Computer settings
gui.computercraft:config.log_peripheral_errors=Log peripheral errors
gui.computercraft:config.enable_command_block=Enable command block peripheral
gui.computercraft:config.modem_range=Modem range (default)
gui.computercraft:config.modem_high_altitude_range=Modem range (high-altitude)