Skip to content

Commit ef2adf3

Browse files
committed
RunService: use InvocationTargetException instead
The code migrated from scijava/scripting-java used ScriptException. But now that this code is part of core SJC, and is not script-specific anymore, it makes more sense to use InvocationTargetException instead.
1 parent 8272eb0 commit ef2adf3

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/main/java/org/scijava/main/run/MainRunner.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import java.lang.reflect.InvocationTargetException;
3535
import java.lang.reflect.Method;
3636

37-
import javax.script.ScriptException;
38-
3937
import org.scijava.Priority;
4038
import org.scijava.log.LogService;
4139
import org.scijava.plugin.Parameter;
@@ -57,18 +55,15 @@ public class MainRunner extends AbstractClassRunner {
5755
// -- ClassRunner methods --
5856

5957
@Override
60-
public void run(final Class<?> c) throws ScriptException {
58+
public void run(final Class<?> c) throws InvocationTargetException {
6159
try {
6260
getMain(c).invoke(null, new Object[] { new String[0] });
6361
}
6462
catch (final IllegalArgumentException exc) {
65-
throw new ScriptException(exc);
63+
throw new InvocationTargetException(exc);
6664
}
6765
catch (final IllegalAccessException exc) {
68-
throw new ScriptException(exc);
69-
}
70-
catch (final InvocationTargetException exc) {
71-
throw new ScriptException(exc);
66+
throw new InvocationTargetException(exc);
7267
}
7368
}
7469

src/main/java/org/scijava/run/ClassRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
package org.scijava.run;
3333

34-
import javax.script.ScriptException;
34+
import java.lang.reflect.InvocationTargetException;
3535

3636
import org.scijava.plugin.HandlerPlugin;
3737
import org.scijava.plugin.Plugin;
@@ -53,6 +53,6 @@
5353
public interface ClassRunner extends HandlerPlugin<Class<?>> {
5454

5555
/** Executes the given class. */
56-
void run(Class<?> c) throws ScriptException;
56+
void run(Class<?> c) throws InvocationTargetException;
5757

5858
}

src/main/java/org/scijava/run/DefaultRunService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
package org.scijava.run;
3333

34-
import javax.script.ScriptException;
34+
import java.lang.reflect.InvocationTargetException;
3535

3636
import org.scijava.log.LogService;
3737
import org.scijava.plugin.AbstractHandlerService;
@@ -55,14 +55,14 @@ public class DefaultRunService extends
5555
// -- RunService methods --
5656

5757
@Override
58-
public void run(final Class<?> c) throws ScriptException {
58+
public void run(final Class<?> c) throws InvocationTargetException {
5959
for (final ClassRunner runner : getInstances()) {
6060
if (runner.supports(c)) {
6161
runner.run(c);
6262
return;
6363
}
6464
}
65-
log.error("Unknown class type: " + c.getName());
65+
throw new IllegalArgumentException("Unknown class type: " + c.getName());
6666
}
6767

6868
// -- PTService methods --

src/main/java/org/scijava/run/RunService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
package org.scijava.run;
3333

34-
import javax.script.ScriptException;
34+
import java.lang.reflect.InvocationTargetException;
3535

3636
import org.scijava.plugin.HandlerService;
3737
import org.scijava.service.SciJavaService;
@@ -46,6 +46,6 @@ public interface RunService extends
4646
{
4747

4848
/** Executes the given class using the most appropriate handler. */
49-
void run(Class<?> c) throws ScriptException;
49+
void run(Class<?> c) throws InvocationTargetException;
5050

5151
}

0 commit comments

Comments
 (0)