Refactor and extend new ExitCode logic

This commit is contained in:
Reinhard Pointner 2019-02-21 21:10:24 +07:00
parent 111e4661d9
commit f8e3c3460d
4 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,4 @@
package net.filebot.cli;
package net.filebot;
public class ExitCode {
@ -12,6 +12,6 @@ public class ExitCode {
public static final int DIE = 4;
public static final int NO_OPERATION = 10;
public static final int NOOP = 100;
}

View File

@ -3,10 +3,10 @@ package net.filebot;
import static java.awt.GraphicsEnvironment.*;
import static java.util.Arrays.*;
import static java.util.stream.Collectors.*;
import static net.filebot.ExitCode.*;
import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.Settings.*;
import static net.filebot.cli.ExitCode.*;
import static net.filebot.ui.GettingStartedUtil.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.FileUtilities.getChildren;

View File

@ -1,10 +1,10 @@
package net.filebot.cli;
import static java.nio.charset.StandardCharsets.*;
import static net.filebot.ExitCode.*;
import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.Settings.*;
import static net.filebot.cli.ExitCode.*;
import static net.filebot.util.ExceptionUtilities.*;
import static net.filebot.util.FileUtilities.*;
@ -75,6 +75,7 @@ public class ArgumentProcessor {
return d.getExitCode();
}
log.log(Level.SEVERE, e, e::getMessage);
return ERROR;
}

View File

@ -40,6 +40,7 @@ import groovy.lang.Closure;
import groovy.lang.MissingPropertyException;
import groovy.lang.Script;
import groovy.xml.MarkupBuilder;
import net.filebot.ExitCode;
import net.filebot.HistorySpooler;
import net.filebot.RenameAction;
import net.filebot.StandardRenameAction;
@ -171,11 +172,11 @@ public abstract class ScriptShellBaseClass extends Script {
}
public void die(Object cause) throws Throwable {
die(ExitCode.DIE, cause);
die(cause, ExitCode.DIE);
}
public void die(int exitCode, Object... cause) throws Throwable {
throw new ScriptDeath(exitCode, getMessage(cause));
public void die(Object cause, int exitCode) throws Throwable {
throw new ScriptDeath(exitCode, String.valueOf(cause));
}
// define global variable: _args