1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-01-13 06:48:04 -05:00

* make sure the the original args array is available during runtime for debugging purposes

This commit is contained in:
Reinhard Pointner 2014-01-05 06:58:31 +00:00
parent 7d814d7b77
commit fea363c67d
3 changed files with 51 additions and 35 deletions

View File

@ -1,5 +1,6 @@
package net.sourceforge.filebot.cli;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static net.sourceforge.tuned.FileUtilities.*;
@ -172,4 +173,14 @@ public class ArgumentBean {
return Level.parse(log.toUpperCase());
}
private final String[] array;
public ArgumentBean(String... array) {
this.array = array;
}
public List<String> getArray() {
return unmodifiableList(asList(array));
}
}

View File

@ -41,7 +41,7 @@ public class ArgumentProcessor {
}
public ArgumentBean parse(String[] args) throws CmdLineException {
ArgumentBean bean = new ArgumentBean();
ArgumentBean bean = new ArgumentBean(args);
CmdLineParser parser = new CmdLineParser(bean);
parser.parseArgument(args);
return bean;
@ -126,7 +126,13 @@ public class ArgumentProcessor {
CLILogger.finest("Done ヾ(@⌒ー⌒@)");
return 0;
} catch (Throwable e) {
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e).getClass() == Exception.class ? null : getRootCause(e));
if (e.getClass() == Exception.class) {
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)));
} else if (e.getClass() == IllegalArgumentException.class) {
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), String.format("%s %s", getRootCauseMessage(e), args.getArray())));
} else {
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e));
}
CLILogger.finest("Failure (°_°)");
return -1;
}
@ -159,11 +165,10 @@ public class ArgumentProcessor {
}
@Override
public URI getScriptLocation(String input) {
public URI getScriptLocation(String input) throws Exception {
try {
return new URL(input).toURI();
} catch (Exception _) {
try {
// system:in
if (input.equals("system:in")) {
return new URI("system", "in", null);
@ -192,9 +197,6 @@ public class ArgumentProcessor {
throw new FileNotFoundException(file.getPath());
}
return file.getAbsoluteFile().toURI();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
}

View File

@ -60,7 +60,7 @@ public class ScriptShell {
public static interface ScriptProvider {
public URI getScriptLocation(String input);
public URI getScriptLocation(String input) throws Exception;
public Script fetchScript(URI uri) throws Exception;
}
@ -103,6 +103,9 @@ public class ScriptShell {
throw e.getException();
}
} catch (Throwable e) {
while (e.getClass() == ScriptException.class && e.getCause() != null) {
e = e.getCause();
}
throw StackTraceUtils.deepSanitize(e); // make Groovy stack human-readable
}
}