1234567891011121314151617181920212223242526 |
- package com.caimei.annotation;
- import com.caimei.model.ResponseJson;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.ControllerAdvice;
- import org.springframework.web.bind.annotation.ExceptionHandler;
- import org.springframework.web.bind.annotation.ResponseBody;
- /**
- * ApI幂等异常处理
- *
- * @author : Charles
- * @date : 2021/3/29
- */
- @Slf4j
- @ControllerAdvice
- public class IdempotentExceptionHandler {
- @ExceptionHandler(IdempotentException.class)
- @ResponseBody
- public ResponseJson convertExceptionMsg(Exception e) {
- //自定义逻辑,可返回其他值
- log.error("ApI幂等错误拦截,错误信息:", e);
- return ResponseJson.error("幂等异常处理:" + e.getMessage());
- }
- }
|