diff --git a/servo/src/main/java/com/yvan/workbench/autoconfigure/AppAutoConfiguration.java b/servo/src/main/java/com/yvan/workbench/autoconfigure/AppAutoConfiguration.java index 4d5cb8e..d7a3749 100644 --- a/servo/src/main/java/com/yvan/workbench/autoconfigure/AppAutoConfiguration.java +++ b/servo/src/main/java/com/yvan/workbench/autoconfigure/AppAutoConfiguration.java @@ -17,8 +17,10 @@ import org.clever.core.AppBasicsConfig; import org.clever.core.AppContextHolder; import org.clever.core.Assert; import org.clever.core.ResourcePathUtils; +import org.clever.core.exception.ExceptionUtils; import org.clever.core.json.jackson.JacksonConfig; import org.clever.core.mapper.JacksonMapper; +import org.clever.core.model.response.ErrorResponse; import org.clever.core.reflection.ReflectionsUtils; import org.clever.core.task.StartupTaskBootstrap; import org.clever.data.jdbc.JdbcBootstrap; @@ -33,6 +35,7 @@ import org.clever.web.config.HttpConfig; import org.clever.web.config.WebConfig; import org.clever.web.filter.*; import org.clever.web.utils.ApplyWebConfig; +import org.clever.web.utils.GlobalExceptionHandler; import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.web.servlet.FilterRegistrationBean; @@ -122,10 +125,10 @@ public class AppAutoConfiguration { public MultipartConfigElement multipartConfigElement(AppBasicsConfig appBasicsConfig, WebConfig webConfig) { HttpConfig.Multipart multipart = webConfig.getHttp().getMultipart(); return new MultipartConfigElement( - ResourcePathUtils.getAbsolutePath(appBasicsConfig.getRootPath(), multipart.getLocation()), - multipart.getMaxFileSize().toBytes(), - multipart.getMaxTotalRequestSize().toBytes(), - (int) multipart.getMaxInMemoryFileSize().toBytes() + ResourcePathUtils.getAbsolutePath(appBasicsConfig.getRootPath(), multipart.getLocation()), + multipart.getMaxFileSize().toBytes(), + multipart.getMaxTotalRequestSize().toBytes(), + (int) multipart.getMaxInMemoryFileSize().toBytes() ); } @@ -193,6 +196,11 @@ public class AppAutoConfiguration { @Bean public FilterRegistrationBean exceptionHandlerFilter() { + GlobalExceptionHandler.setDefaultHandler((exception, request, response) -> { + ErrorResponse res = GlobalExceptionHandler.newErrorResponse(request, exception); + res.setError(ExceptionUtils.getStackTraceAsString(exception)); + return res; + }); FilterRegistrationBean filterBean = new FilterRegistrationBean<>(); filterBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 300); filterBean.addUrlPatterns(PathConstants.ALL);