template.process(context, out);
return IO.copy(new StringReader(writer.toString()), out);
} catch (TemplateException e) {
throw new ViewException(e.getMessage());
} catch (IOException e) {
throw new FileNotFoundException(String.format("%s not found.", path));
} catch (Exception e) {
if (e instanceof RedirectException || e.getCause() instanceof RedirectException) {
throw new RedirectException();
}else{
throw new ViewException(e.getMessage()); // generic??
}
}
}