mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-02-11 14:52:01 +08:00
make template error logging nicer
This commit is contained in:
parent
5eb30e467d
commit
96ab48da57
@ -1,5 +1,7 @@
|
||||
package me.minidigger.hangar.config;
|
||||
|
||||
import freemarker.template.TemplateException;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -15,6 +17,7 @@ import org.springframework.web.servlet.resource.VersionResourceResolver;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@EnableWebMvc
|
||||
@ -34,6 +37,14 @@ public class MvcConfig implements WebMvcConfigurer {
|
||||
public FreeMarkerConfigurer freemarkerConfig() {
|
||||
FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
|
||||
freeMarkerConfigurer.setTemplateLoaderPath("classpath:templates");
|
||||
try {
|
||||
freeMarkerConfigurer.afterPropertiesSet();
|
||||
} catch (IOException | TemplateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
freeMarkerConfigurer.getConfiguration().setOutputEncoding("UTF-8");
|
||||
freeMarkerConfigurer.getConfiguration().setLogTemplateExceptions(false);
|
||||
freeMarkerConfigurer.getConfiguration().setTemplateExceptionHandler((te, env, out) -> System.out.println("[Template Error] " + te.getMessage()));
|
||||
return freeMarkerConfigurer;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user