From fb884c017adf4b7395043ab23faaf2086f13e88a Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 21 Apr 2014 14:09:31 +0000 Subject: [PATCH] * allow die(Throwable) usage --- source/net/filebot/cli/ArgumentProcessor.java | 2 +- source/net/filebot/cli/ScriptDeath.java | 4 ++-- source/net/filebot/cli/ScriptShellBaseClass.java | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/cli/ArgumentProcessor.java b/source/net/filebot/cli/ArgumentProcessor.java index a02b2d29..39952cd4 100644 --- a/source/net/filebot/cli/ArgumentProcessor.java +++ b/source/net/filebot/cli/ArgumentProcessor.java @@ -112,7 +112,7 @@ public class ArgumentProcessor { CLILogger.finest("Done ヾ(@⌒ー⌒@)ノ"); return 0; } catch (ScriptDeath e) { - CLILogger.log(Level.WARNING, e.getMessage()); + 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)); } diff --git a/source/net/filebot/cli/ScriptDeath.java b/source/net/filebot/cli/ScriptDeath.java index 4330015e..33ea629d 100644 --- a/source/net/filebot/cli/ScriptDeath.java +++ b/source/net/filebot/cli/ScriptDeath.java @@ -6,8 +6,8 @@ public class ScriptDeath extends Throwable { super(message); } - public ScriptDeath(String message, Throwable cause) { - super(message, cause); + public ScriptDeath(Throwable cause) { + super(cause); } } diff --git a/source/net/filebot/cli/ScriptShellBaseClass.java b/source/net/filebot/cli/ScriptShellBaseClass.java index a7a656fe..6a94ea29 100644 --- a/source/net/filebot/cli/ScriptShellBaseClass.java +++ b/source/net/filebot/cli/ScriptShellBaseClass.java @@ -126,8 +126,11 @@ public abstract class ScriptShellBaseClass extends Script { // StackTraceUtils.deepSanitize(t).printStackTrace(); } - public void die(String message) throws Throwable { - throw new ScriptDeath(message); + public void die(Object cause) throws Throwable { + if (cause instanceof Throwable) { + throw new ScriptDeath((Throwable) cause); + } + throw new ScriptDeath(cause.toString()); } // define global variable: _args @@ -473,7 +476,7 @@ public abstract class ScriptShellBaseClass extends Script { return options; } - private RenameAction getRenameFunction(final Object obj) { + public RenameAction getRenameFunction(final Object obj) { if (obj instanceof RenameAction) { return (RenameAction) obj; }