Collapse catch blocks
This commit is contained in:
parent
3f8b35343c
commit
8df1fa881a
@ -35,9 +35,7 @@ public class CommandlineInterpreter {
|
|||||||
try {
|
try {
|
||||||
final PostfixExpression pe = PostfixExpression.fromInfix(string);
|
final PostfixExpression pe = PostfixExpression.fromInfix(string);
|
||||||
System.out.println(pe.calculate());
|
System.out.println(pe.calculate());
|
||||||
} catch (UnparsableExpressionException e) {
|
} catch (UnparsableExpressionException | UnknownFunctionException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (UnknownFunctionException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,7 @@ class ComponentHandler extends AbstractElementHandler {
|
|||||||
RocketComponent c;
|
RocketComponent c;
|
||||||
try {
|
try {
|
||||||
c = constructor.newInstance();
|
c = constructor.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
throw new BugException("Error constructing component.", e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException("Error constructing component.", e);
|
throw new BugException("Error constructing component.", e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
|
@ -305,8 +305,7 @@ public abstract class BaseHandler<C extends RocketComponent> extends AbstractEle
|
|||||||
if (method != null) {
|
if (method != null) {
|
||||||
method.invoke(component, material);
|
method.invoke(component, material);
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException ignored) {
|
} catch (IllegalAccessException | InvocationTargetException ignored) {
|
||||||
} catch (InvocationTargetException ignored) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +60,7 @@ public class FlightConfigurationModifier<E extends FlightConfigurableParameter<E
|
|||||||
try {
|
try {
|
||||||
configName = configName.substring(0, 1).toUpperCase(Locale.ENGLISH) + configName.substring(1);
|
configName = configName.substring(0, 1).toUpperCase(Locale.ENGLISH) + configName.substring(1);
|
||||||
configGetter = new Method(componentClass.getMethod("get" + configName));
|
configGetter = new Method(componentClass.getMethod("get" + configName));
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException | NoSuchMethodException e) {
|
||||||
throw new BugException("Trying to find method get/set" + configName + " in class " + componentClass, e);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new BugException("Trying to find method get/set" + configName + " in class " + componentClass, e);
|
throw new BugException("Trying to find method get/set" + configName + " in class " + componentClass, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,7 @@ public abstract class GenericModifier<T> extends AbstractSimulationModifier {
|
|||||||
methodName = methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1);
|
methodName = methodName.substring(0, 1).toUpperCase(Locale.ENGLISH) + methodName.substring(1);
|
||||||
getter = new Method(modifiedClass.getMethod("get" + methodName));
|
getter = new Method(modifiedClass.getMethod("get" + methodName));
|
||||||
setter = new Method(modifiedClass.getMethod("set" + methodName, double.class));
|
setter = new Method(modifiedClass.getMethod("set" + methodName, double.class));
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException | NoSuchMethodException e) {
|
||||||
throw new BugException("Trying to find method get/set" + methodName + " in class " + modifiedClass, e);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new BugException("Trying to find method get/set" + methodName + " in class " + modifiedClass, e);
|
throw new BugException("Trying to find method get/set" + methodName + " in class " + modifiedClass, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,6 @@ public class DoubleUnitColumnParser extends BaseUnitColumnParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
props.put(propKey, value);
|
props.put(propKey, value);
|
||||||
} catch (NumberFormatException nex) {
|
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,7 @@ public class Reflection {
|
|||||||
public Object invoke(Object obj, Object... args) {
|
public Object invoke(Object obj, Object... args) {
|
||||||
try {
|
try {
|
||||||
return method.invoke(obj, args);
|
return method.invoke(obj, args);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new BugException("Error while invoking method '" + method + "'. " +
|
|
||||||
"Please report this as a bug.", e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException("Error while invoking method '" + method + "'. " +
|
throw new BugException("Error while invoking method '" + method + "'. " +
|
||||||
"Please report this as a bug.", e);
|
"Please report this as a bug.", e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
@ -132,8 +129,7 @@ public class Reflection {
|
|||||||
Class<?> c = Class.forName(name);
|
Class<?> c = Class.forName(name);
|
||||||
java.lang.reflect.Method m = c.getMethod(method, params);
|
java.lang.reflect.Method m = c.getMethod(method, params);
|
||||||
return new Reflection.Method(m);
|
return new Reflection.Method(m);
|
||||||
} catch (ClassNotFoundException ignore) {
|
} catch (ClassNotFoundException | NoSuchMethodException ignore) {
|
||||||
} catch (NoSuchMethodException ignore) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentclass = currentclass.getSuperclass();
|
currentclass = currentclass.getSuperclass();
|
||||||
@ -174,11 +170,7 @@ public class Reflection {
|
|||||||
return constructor.newInstance(params);
|
return constructor.newInstance(params);
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException ignore) {
|
} catch (ClassNotFoundException ignore) {
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
|
||||||
throw new BugException("Construction of " + name + " failed", e);
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new BugException("Construction of " + name + " failed", e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException("Construction of " + name + " failed", e);
|
throw new BugException("Construction of " + name + " failed", e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
|
@ -792,9 +792,7 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return (Double) getMethod.invoke(source) * multiplier;
|
return (Double) getMethod.invoke(source) * multiplier;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new BugException("Unable to invoke getMethod of " + this, e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException("Unable to invoke getMethod of " + this, e);
|
throw new BugException("Unable to invoke getMethod of " + this, e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
@ -829,9 +827,7 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
|
|||||||
setMethod.invoke(source, v / multiplier);
|
setMethod.invoke(source, v / multiplier);
|
||||||
// Make sure to notify all the listeners that have registered
|
// Make sure to notify all the listeners that have registered
|
||||||
fireStateChanged();
|
fireStateChanged();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new BugException("Unable to invoke setMethod of " + this, e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException("Unable to invoke setMethod of " + this, e);
|
throw new BugException("Unable to invoke setMethod of " + this, e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
@ -855,9 +851,7 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return (Boolean) getAutoMethod.invoke(source);
|
return (Boolean) getAutoMethod.invoke(source);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new BugException("Method call failed", e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException("Method call failed", e);
|
throw new BugException("Method call failed", e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
@ -881,9 +875,7 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
|
|||||||
lastAutomatic = auto;
|
lastAutomatic = auto;
|
||||||
try {
|
try {
|
||||||
setAutoMethod.invoke(source, auto);
|
setAutoMethod.invoke(source, auto);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new BugException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException(e);
|
throw new BugException(e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
|
@ -201,9 +201,7 @@ public class IntegerModel implements StateChangeListener, Invalidatable {
|
|||||||
public int getValue() {
|
public int getValue() {
|
||||||
try {
|
try {
|
||||||
return (Integer) getMethod.invoke(source);
|
return (Integer) getMethod.invoke(source);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new BugException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException(e);
|
throw new BugException(e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
@ -224,9 +222,7 @@ public class IntegerModel implements StateChangeListener, Invalidatable {
|
|||||||
try {
|
try {
|
||||||
setMethod.invoke(source, v);
|
setMethod.invoke(source, v);
|
||||||
fireStateChanged();
|
fireStateChanged();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
throw new BugException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException(e);
|
throw new BugException(e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
|
@ -461,9 +461,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
|
|||||||
RocketComponent component;
|
RocketComponent component;
|
||||||
try {
|
try {
|
||||||
component = (RocketComponent) constructor.newInstance();
|
component = (RocketComponent) constructor.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException | IllegalAccessException e) {
|
||||||
throw new BugException("Could not construct new instance of class " + constructor, e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new BugException("Could not construct new instance of class " + constructor, e);
|
throw new BugException("Could not construct new instance of class " + constructor, e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw Reflection.handleWrappedException(e);
|
throw Reflection.handleWrappedException(e);
|
||||||
|
@ -158,9 +158,7 @@ public class PrintController {
|
|||||||
writer.close();
|
writer.close();
|
||||||
idoc.close();
|
idoc.close();
|
||||||
}
|
}
|
||||||
catch (DocumentException e) {
|
catch (DocumentException | ExceptionConverter e) {
|
||||||
}
|
|
||||||
catch (ExceptionConverter ec) {
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (outputFile != null) {
|
if (outputFile != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user