diff --git a/docs/index.html b/docs/index.html index 1c77dc03..1585e548 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3929,7 +3929,7 @@

diff --git a/framework/modules/boot-starter/src/main/java/group/idealworld/dew/core/web/error/ErrorController.java b/framework/modules/boot-starter/src/main/java/group/idealworld/dew/core/web/error/ErrorController.java index 2873d47d..41cde3f0 100644 --- a/framework/modules/boot-starter/src/main/java/group/idealworld/dew/core/web/error/ErrorController.java +++ b/framework/modules/boot-starter/src/main/java/group/idealworld/dew/core/web/error/ErrorController.java @@ -21,6 +21,7 @@ import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.util.ObjectUtils; @@ -98,9 +99,10 @@ public Object error(HttpServletRequest request) throws InvocationTargetException } else { path = ((RequestFacade) ((ServletRequestWrapper) request).getRequest()).getRequestURI(); } - int httpCode = (int) error.getOrDefault("status", -1); + HttpStatus httpStatus = getStatus(request); + int httpCode = httpStatus.value(); String message = error.getOrDefault("message", "").toString(); - String exMsg = (String) error.getOrDefault("error", ""); + String exMsg = httpStatus.getReasonPhrase(); List exDetail = null; if (error.containsKey("errors") && !((List) error.get("errors")).isEmpty()) { exDetail = (List) error.get("errors"); @@ -184,7 +186,7 @@ private static Object[] error(HttpServletRequest request, busCode, message); var resp = StandardResp.custom(busCode, path, String.format("[%s]%s", exMsg, message)); String body = $.json.toJsonString(resp); - return new Object[] {httpCode, body}; + return new Object[]{httpCode, body}; } /**