zhaoqiaobo
3 months ago
1 changed files with 25 additions and 0 deletions
@ -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…
Reference in new issue