From aee050a412cb6d61bb384b1e5b1d5667ec075f03 Mon Sep 17 00:00:00 2001 From: zhouxiunai <154707516@qq.com> Date: Thu, 20 Dec 2018 18:03:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=9C=AA=E7=9F=A5=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84http=E9=94=99=E8=AF=AF=E7=A0=81=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=88=90500=20=EF=BC=8C=E4=BE=BF=E4=BA=8E=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/handler/ExceptionHandle.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java b/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java index 7383747..f6a5592 100644 --- a/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java +++ b/src/main/java/com/gzzn/omms/adminapi/exception/handler/ExceptionHandle.java @@ -1,11 +1,17 @@ package com.gzzn.omms.adminapi.exception.handler; +import java.util.HashMap; +import java.util.Map; + import org.jboss.logging.MDC; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; import com.gzzn.omms.adminapi.dto.ResponseDto; import com.gzzn.omms.adminapi.enums.ResultCode; @@ -39,8 +45,7 @@ public class ExceptionHandle { * @return */ @ExceptionHandler(value = Exception.class) - @ResponseBody - public ResponseDto exceptionHandle(Exception e) + public ResponseEntity> exceptionHandle(Exception e) { logger.error("[未知系统异常]",e); @@ -56,6 +61,9 @@ public class ExceptionHandle { reponseErrMsg = "requestId:"+requestId + ",errorMsg:null"; } - return ResponseDto.failure(ResultCode.SYSTEM_INNER_ERROR,reponseErrMsg); + return new ResponseEntity>( + ResponseDto.failure(ResultCode.SYSTEM_INNER_ERROR,reponseErrMsg), + HttpStatus.INTERNAL_SERVER_ERROR + ); } }