将未知错误的http错误码设置成500 ,便于调试
This commit is contained in:
@@ -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<ResponseDto<String>> 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<String>>(
|
||||
ResponseDto.failure(ResultCode.SYSTEM_INNER_ERROR,reponseErrMsg),
|
||||
HttpStatus.INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user