use of freemarker.template.utility.UndeclaredThrowableException in project freemarker by apache.
the class PageContextFactory method getCurrentPageContext.
static FreeMarkerPageContext getCurrentPageContext() throws TemplateModelException {
Environment env = Environment.getCurrentEnvironment();
TemplateModel pageContextModel = env.getGlobalVariable(PageContext.PAGECONTEXT);
if (pageContextModel instanceof FreeMarkerPageContext) {
return (FreeMarkerPageContext) pageContextModel;
}
try {
FreeMarkerPageContext pageContext = (FreeMarkerPageContext) pageContextImpl.newInstance();
env.setGlobalVariable(PageContext.PAGECONTEXT, pageContext);
return pageContext;
} catch (IllegalAccessException e) {
throw new IllegalAccessError(e.getMessage());
} catch (InstantiationException e) {
throw new UndeclaredThrowableException(e);
}
}
use of freemarker.template.utility.UndeclaredThrowableException in project be5 by DevelopmentOnTheEdge.
the class Environment method visitAndTransform.
/**
* "Visit" the template element, passing the output
* through a TemplateTransformModel
* @param element the element to visit through a transform
* @param transform the transform to pass the element output
* through
* @param args optional arguments fed to the transform
*/
void visitAndTransform(TemplateElement element, TemplateTransformModel transform, Map args) throws TemplateException, IOException {
try {
Writer tw = transform.getWriter(out, args);
if (tw == null)
tw = EMPTY_BODY_WRITER;
TransformControl tc = tw instanceof TransformControl ? (TransformControl) tw : null;
Writer prevOut = out;
out = tw;
try {
if (tc == null || tc.onStart() != TransformControl.SKIP_BODY) {
do {
if (element != null) {
visitByHiddingParent(element);
}
} while (tc != null && tc.afterBody() == TransformControl.REPEAT_EVALUATION);
}
} catch (Throwable t) {
try {
if (tc != null) {
tc.onError(t);
} else {
throw t;
}
} catch (TemplateException e) {
throw e;
} catch (IOException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
}
} finally {
out = prevOut;
tw.close();
}
} catch (TemplateException te) {
handleTemplateException(te);
}
}
Aggregations