Browse Source

feat(all): 全局自定义异常

1 修改报表模块自定义异常返回
fix-sign
zhaoqiaobo 3 months ago
parent
commit
1e141d1929
  1. 25
      blade-service/logpm-report/src/main/java/com/logpm/report/config/GlobalExceptionHandler.java

25
blade-service/logpm-report/src/main/java/com/logpm/report/config/GlobalExceptionHandler.java

@ -0,0 +1,25 @@
package com.logpm.report.config;
import com.alibaba.fastjson.JSONObject;
import org.springblade.common.exception.CustomerException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/**
* @Author: zqb
* @Date: 2024/11/13
*/
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(CustomerException.class)
public ResponseEntity<Object> handleCustomException(CustomerException e) {
JSONObject js = new JSONObject();
js.put("code", e.getCode());
js.put("msg", e.getMessage());
return new ResponseEntity<>(js, HttpStatus.BAD_REQUEST);
}
}
Loading…
Cancel
Save