* 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 ヾ(@⌒ー⌒@)");
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));
}

View File

@ -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);
}
}

View File

@ -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;
}