Unify macro error handling, and don't dump stack traces for macro errors.

This commit is contained in:
hns 2008-10-16 13:50:29 +00:00
parent ffff56465f
commit 3af404d39e

View file

@ -634,7 +634,7 @@ public final class Skin {
}
if ((sandbox != null) && !sandbox.contains(name)) {
throw new RuntimeException("Macro " + name + " not allowed in sandbox");
throw new MacroException("Macro not allowed in sandbox: " + name);
}
Object handler = null;
@ -700,7 +700,7 @@ public final class Skin {
buffer.setLength(bufLength);
}
} else if (standardParams.verboseFailmode(handler, engine)) {
throw new UnhandledMacroException(name);
throw new MacroException("Unhandled macro: " + name);
}
} else {
value = engine.getProperty(handler, propName);
@ -708,7 +708,7 @@ public final class Skin {
return filter(value, cx);
}
} else if (standardParams.verboseFailmode(handler, engine)) {
throw new UnhandledMacroException(name);
throw new MacroException("Unhandled macro: " + name);
}
return filter(null, cx);
}
@ -781,8 +781,8 @@ public final class Skin {
throw concur;
} catch (TimeoutException timeout) {
throw timeout;
} catch (UnhandledMacroException unhandled) {
String msg = "Unhandled Macro: " + unhandled.getMessage();
} catch (MacroException mx) {
String msg = mx.getMessage();
cx.reval.getResponse().write(" [" + msg + "] ");
app.logError(msg);
} catch (Exception x) {
@ -811,9 +811,9 @@ public final class Skin {
throws Exception {
if (name == null) {
throw new RuntimeException("Empty macro filter");
throw new MacroException("Empty macro filter");
} else if (sandbox != null && !sandbox.contains(name)) {
throw new RuntimeException("Macro " + name + " not allowed in sandbox");
throw new MacroException("Macro not allowed in sandbox: " + name);
}
Object handlerObject = null;
@ -835,7 +835,7 @@ public final class Skin {
return filter(retval, cx);
} else {
throw new RuntimeException("Undefined Filter " + name);
throw new MacroException("Undefined macro filter: " + name);
}
}
@ -1121,12 +1121,13 @@ public final class Skin {
}
/**
* Exception type for unhandled macros
* Exception type for unhandled, forbidden or failed macros
*/
class UnhandledMacroException extends Exception {
UnhandledMacroException(String name) {
super(name);
class MacroException extends Exception {
MacroException(String message) {
super(message);
}
}
}