MyExceptionHandler.java 648 Bytes
package com.ruoyi.interceptor;

import com.ruoyi.common.TipEnum;
import com.ruoyi.common.core.domain.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author liujun
 * @date 2024年08月14日 10:52
 */
@Slf4j
@ControllerAdvice
public class MyExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    public <T> ResponseResult<T> exceptionHandler(Exception e) {
        log.error(e.getMessage(), e);
        return ResponseResult.error(TipEnum.TIP_504.getCode(), TipEnum.TIP_504.getMsg());
    }
}