* allow die(Throwable) usage

This commit is contained in:
Reinhard Pointner 2014-04-21 14:09:31 +00:00
parent b2150b3392
commit fb884c017a
3 changed files with 9 additions and 6 deletions

View File

@ -112,7 +112,7 @@ public class ArgumentProcessor {
CLILogger.finest("Done ヾ(@⌒ー⌒@)"); CLILogger.finest("Done ヾ(@⌒ー⌒@)");
return 0; return 0;
} catch (ScriptDeath e) { } catch (ScriptDeath e) {
CLILogger.log(Level.WARNING, e.getMessage()); CLILogger.log(Level.WARNING, e.getMessage(), e.getCause());
} catch (Throwable e) { } catch (Throwable e) {
CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e)); CLILogger.log(Level.SEVERE, String.format("%s: %s", getRootCause(e).getClass().getSimpleName(), getRootCauseMessage(e)), getRootCause(e));
} }

View File

@ -6,8 +6,8 @@ public class ScriptDeath extends Throwable {
super(message); super(message);
} }
public ScriptDeath(String message, Throwable cause) { public ScriptDeath(Throwable cause) {
super(message, cause); super(cause);
} }
} }

View File

@ -126,8 +126,11 @@ public abstract class ScriptShellBaseClass extends Script {
// StackTraceUtils.deepSanitize(t).printStackTrace(); // StackTraceUtils.deepSanitize(t).printStackTrace();
} }
public void die(String message) throws Throwable { public void die(Object cause) throws Throwable {
throw new ScriptDeath(message); if (cause instanceof Throwable) {
throw new ScriptDeath((Throwable) cause);
}
throw new ScriptDeath(cause.toString());
} }
// define global variable: _args // define global variable: _args
@ -473,7 +476,7 @@ public abstract class ScriptShellBaseClass extends Script {
return options; return options;
} }
private RenameAction getRenameFunction(final Object obj) { public RenameAction getRenameFunction(final Object obj) {
if (obj instanceof RenameAction) { if (obj instanceof RenameAction) {
return (RenameAction) obj; return (RenameAction) obj;
} }