处理错误

master
youys 2 years ago
parent 9f8d19c5c7
commit d5fe4abd47

@ -2,7 +2,7 @@ package net.educoder.handler;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.educoder.exception.BridgeException; import net.educoder.exception.BusinessException;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
@ -19,10 +19,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice @ControllerAdvice
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
@ExceptionHandler(BridgeException.class) @ExceptionHandler(BusinessException.class)
@ResponseBody @ResponseBody
public ResponseEntity<JSONObject> handleBridgeExceptions(BridgeException e) { public ResponseEntity<JSONObject> handleBridgeExceptions(BusinessException e) {
log.error("捕获到BridgeException", e); log.error("捕获到BusinessException", e);
JSONObject jsonObj = new JSONObject(); JSONObject jsonObj = new JSONObject();
jsonObj.put("code", e.getCode()); jsonObj.put("code", e.getCode());

Loading…
Cancel
Save