Use multiple catch, try-with-resources, replace system.out and e.printStackTrace

This commit is contained in:
mezz committed 2017-06-27 22:57:10 -07:00
1 parent 10ca404e9e
commit 93025510ae
27 files changed
+62 -132

No files matched your search

@@ -234,7 +234,7 @@ public class DimensionManager
}
catch (Exception e)
{
System.err.println("Cannot Hotload Dim: " + e.getMessage());
FMLLog.log.error("Cannot Hotload Dim: {}", dim, e);
return; // If a provider hasn't been registered then we can't hotload the dim
}
MinecraftServer mcServer = overworld.getMinecraftServer();
@@ -348,7 +348,7 @@ public class DimensionManager
}
catch (MinecraftException e)
{
e.printStackTrace();
FMLLog.log.error("Caught an exception while saving all chunks:", e);
}
finally
{
@@ -421,7 +421,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
}
catch (Exception e)
{
e.printStackTrace();
log.error("Could not find class for name '{}'.", name, e);
}
}
@@ -124,7 +124,7 @@ public class MinecraftForge
}
catch (Exception e)
{
e.printStackTrace();
FMLLog.log.error("Could not find class for name '{}'.", name, e);
}
}
}
@@ -64,9 +64,7 @@ public enum CapabilityManager
{
try {
return implementation.newInstance();
} catch (InstantiationException e) {
throw Throwables.propagate(e);
} catch (IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException e) {
throw Throwables.propagate(e);
}
}
@@ -26,6 +26,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.ChunkPos;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.fml.common.FMLLog;
import java.io.IOException;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -69,7 +70,7 @@ class ChunkIOProvider implements Runnable
}
catch (IOException e)
{
e.printStackTrace();
FMLLog.log.error("Failed to load chunk async.", e);
}
if (data != null)
@@ -50,6 +50,7 @@ import java.util.regex.Pattern;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Floats;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.GuiConfigEntries;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
@@ -132,8 +133,7 @@ public class Configuration
File fileBak = new File(file.getAbsolutePath() + "_" +
new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".errored");
FMLLog.log.fatal("An exception occurred while loading config file {}. This file will be renamed to {} " +
"and a new config file will be generated.", file.getName(), fileBak.getName());
e.printStackTrace();
"and a new config file will be generated.", file.getName(), fileBak.getName(), e);
file.renameTo(fileBak);
load();
@@ -1047,7 +1047,7 @@ public class Configuration
}
catch (IOException e)
{
e.printStackTrace();
FMLLog.log.error("Error while loading config.", e);
}
finally
{
@@ -1108,7 +1108,7 @@ public class Configuration
}
catch (IOException e)
{
e.printStackTrace();
FMLLog.log.error("Error while saving config.", e);
}
}
@@ -1712,11 +1712,12 @@ public class Configuration
prop.setMaxValue(maxValue);
try
{
return Float.parseFloat(prop.getString()) < minValue ? minValue : (Float.parseFloat(prop.getString()) > maxValue ? maxValue : Float.parseFloat(prop.getString()));
float parseFloat = Float.parseFloat(prop.getString());
return Floats.constrainToRange(parseFloat, minValue, maxValue);
}
catch (Exception e)
{
e.printStackTrace();
FMLLog.log.error("Failed to get float for {}/{}", name, category, e);
}
return defaultValue;
}
@@ -162,7 +162,7 @@ public final class AnimationStateMachine implements IAnimationStateMachine
}
else
{
System.out.println("Unknown special event \"" + event.event() + "\", ignoring");
FMLLog.log.error("Unknown special event \"{}\", ignoring.", event.event());
}
}
}
@@ -230,12 +230,7 @@ public final class AnimationStateMachine implements IAnimationStateMachine
//System.out.println(location + ": " + json);
return asm;
}
catch(IOException e)
{
FMLLog.log.error("Exception loading Animation State Machine {}, skipping", location, e);
return missing;
}
catch(JsonParseException e)
catch(IOException | JsonParseException e)
{
FMLLog.log.error("Exception loading Animation State Machine {}, skipping", location, e);
return missing;
@@ -159,7 +159,7 @@ public class EnumHelper
}
catch (Exception e)
{
e.printStackTrace();
FMLLog.log.error("Error setting up EnumHelper.", e);
}
isSetup = true;
@@ -385,8 +385,8 @@ public class EnumHelper
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException(e.getMessage(), e);
FMLLog.log.error("Error adding enum with EnumHelper.", e);
throw new RuntimeException(e);
}
}