Skip to content

Commit 571c053

Browse files
committed
RunScriptArgument: throw exception for bogus input
If a non-script is given, the supports method will return false. It is a precondition of run that supports return true; if not, we are justified in throwing an exception.
1 parent 4c46edd commit 571c053

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/scijava/script/console/RunScriptArgument.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ public boolean supports(final LinkedList<String> args) {
9494
private void run(final String scriptToRun, final String paramString) {
9595
final File script = getScript(scriptToRun);
9696

97-
// couldn't find anything to run
98-
if (script == null)
99-
return;
97+
if (script == null) {
98+
// couldn't find anything to run
99+
throw new UnsupportedOperationException(//
100+
"Not a script: '" + scriptToRun + "'");
101+
}
100102

101103
final ScriptInfo info = scriptService.getScript(script);
102104

0 commit comments

Comments
 (0)