h6-exam726/cloud-common/src/main/java/com/muyu/common/config/ExceptionHandler.java

23 lines
620 B
Java

package com.muyu.common.config;
import com.muyu.common.result.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* @Author: xe ya ru
* @Description: 异常处理器
* @Data 2024/7/10
* @Version: 1.0
*/
@Log4j2
@RestControllerAdvice
public class ExceptionHandler {
@org.springframework.web.bind.annotation.ExceptionHandler(value = RuntimeException.class)
public Result<String> runtimeExceptionHandler(RuntimeException e) {
log.error("程序请求异常:[{}]",e.getMessage(), e);
return Result.error(e.getMessage());
}
}