mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
* improved error output
This commit is contained in:
parent
6122c6332d
commit
ef4df09197
@ -117,12 +117,14 @@ public class ArgumentProcessor {
|
||||
// script finished successfully
|
||||
CLILogger.finest("Done ヾ(@⌒ー⌒@)ノ");
|
||||
return 0;
|
||||
} catch (CmdlineException e) {
|
||||
CLILogger.log(Level.WARNING, e.getMessage());
|
||||
} catch (ScriptDeath e) {
|
||||
CLILogger.log(Level.WARNING, e.getMessage(), e.getCause());
|
||||
} catch (Throwable e) {
|
||||
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e));
|
||||
if (findCause(e, CmdlineException.class) != null) {
|
||||
CLILogger.log(Level.WARNING, findCause(e, CmdlineException.class).getMessage());
|
||||
} else if (findCause(e, ScriptDeath.class) != null) {
|
||||
CLILogger.log(Level.WARNING, findCause(e, ScriptDeath.class).getMessage());
|
||||
} else {
|
||||
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e));
|
||||
}
|
||||
}
|
||||
|
||||
// script failed
|
||||
|
@ -147,7 +147,7 @@ public abstract class ScriptShellBaseClass extends Script {
|
||||
if (cause instanceof Throwable) {
|
||||
throw new ScriptDeath((Throwable) cause);
|
||||
}
|
||||
throw new ScriptDeath(cause.toString());
|
||||
throw new ScriptDeath(String.valueOf(cause));
|
||||
}
|
||||
|
||||
// define global variable: _args
|
||||
|
@ -1,10 +1,20 @@
|
||||
package net.filebot.util;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public final class ExceptionUtilities {
|
||||
|
||||
public static <T extends Throwable> T shiftStackTrace(T t, int offset) {
|
||||
StackTraceElement[] stackTrace = t.getStackTrace();
|
||||
if (offset < stackTrace.length) {
|
||||
t.setStackTrace(copyOfRange(stackTrace, offset, stackTrace.length));
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Throwable getRootCause(Throwable t) {
|
||||
while (t.getCause() != null) {
|
||||
t = t.getCause();
|
||||
|
Loading…
Reference in New Issue
Block a user