소스 검색

修改AOP对ReportException的处理

sunyj 8 년 전
부모
커밋
057cee5f79
1개의 변경된 파일4개의 추가작업 그리고 7개의 파일을 삭제
  1. 4 7
      src/main/java/com/uas/report/core/advice/ExceptionHandlerAdvice.java

+ 4 - 7
src/main/java/com/uas/report/core/advice/ExceptionHandlerAdvice.java

@@ -43,18 +43,15 @@ public class ExceptionHandlerAdvice {
 		map.put("success", false);
 		if (e instanceof ReportException) {
 			map.put("message", e.getMessage());
-		} else {
-			map.put("message", e.getClass().getSimpleName() + ": " + e.getMessage());
-		}
-		HttpHeaders headers = new HttpHeaders();
-		headers.add("Content-Type", "application/json; charset=utf-8");
-		if (e instanceof ReportException) {
 			ReportException exception = (ReportException) e;
 			if (!StringUtils.isEmpty(exception.getDetailedMessage())) {
 				map.put("detailedMessage", exception.getDetailedMessage());
 			}
-			return new ResponseEntity<ModelMap>(map, headers, HttpStatus.BAD_REQUEST);
+		} else {
+			map.put("message", e.getClass().getSimpleName() + ": " + e.getMessage());
 		}
+		HttpHeaders headers = new HttpHeaders();
+		headers.add("Content-Type", "application/json; charset=utf-8");
 		return new ResponseEntity<ModelMap>(map, headers, HttpStatus.INTERNAL_SERVER_ERROR);
 	}