Clean up uses of deprecated library functions (#4130)

Avoid catching and rethrowing runtime exceptions
Append error messages to exceptions instead of the log
This commit is contained in:
Ben Staddon authored and mezz committed 2017-07-12 21:50:28 -07:00
1 parent ead0e81025
commit 0fde64ac38
44 files changed
+118 -232

No files matched your search

@@ -26,11 +26,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.logging.log4j.Level;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
@@ -307,10 +304,10 @@ public class ConfigManager
{
newInstance = f.get(instance);
}
catch (Exception e)
catch (IllegalAccessException e)
{
//This should never happen. Previous checks should eliminate this.
Throwables.propagate(e);
throw new RuntimeException(e);
}
String sub = (category.isEmpty() ? "" : category + ".") + getName(f).toLowerCase(Locale.ENGLISH);
@@ -76,7 +76,7 @@ public class Configuration
private static final String CONFIG_VERSION_MARKER = "~CONFIG_VERSION";
private static final Pattern CONFIG_START = Pattern.compile("START: \"([^\\\"]+)\"");
private static final Pattern CONFIG_END = Pattern.compile("END: \"([^\\\"]+)\"");
public static final CharMatcher allowedProperties = CharMatcher.JAVA_LETTER_OR_DIGIT.or(CharMatcher.anyOf(ALLOWED_CHARS));
public static final CharMatcher allowedProperties = CharMatcher.javaLetterOrDigit().or(CharMatcher.anyOf(ALLOWED_CHARS));
private static Configuration PARENT = null;
File file;
@@ -11,7 +11,6 @@ import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.Set;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import net.minecraftforge.common.config.Config.RangeDouble;
@@ -84,9 +83,9 @@ public abstract class FieldWrapper implements IFieldWrapper
throw new IllegalArgumentException(String.format("The map '%s' of class '%s' must have the key type String!", field.getName(),
field.getDeclaringClass().getCanonicalName()), cce);
}
catch (Exception e)
catch (IllegalAccessException e)
{
Throwables.propagate(e);
throw new RuntimeException(e);
}
ParameterizedType type = (ParameterizedType) field.getGenericType();
@@ -200,11 +199,10 @@ public abstract class FieldWrapper implements IFieldWrapper
Enum enu = (Enum) field.get(instance);
return enu.name();
}
catch (Exception e)
catch (IllegalAccessException e)
{
Throwables.propagate(e);
throw new RuntimeException(e);
}
return null;
}
@Override
@@ -218,9 +216,9 @@ public abstract class FieldWrapper implements IFieldWrapper
{
field.set(instance, enu);
}
catch (Exception e)
catch (IllegalAccessException e)
{
Throwables.propagate(e);
throw new RuntimeException(e);
}
}
@@ -271,11 +269,10 @@ public abstract class FieldWrapper implements IFieldWrapper
{
return field.get(instance);
}
catch (Exception e)
catch (IllegalAccessException e)
{
Throwables.propagate(e);
throw new RuntimeException(e);
}
return null;
}
@Override
@@ -287,9 +284,9 @@ public abstract class FieldWrapper implements IFieldWrapper
{
field.set(instance, value);
}
catch (Exception e)
catch (IllegalAccessException e)
{
Throwables.propagate(e);
throw new RuntimeException(e);
}
}