26 lines
673 B
Java
26 lines
673 B
Java
package com.muyu.config;
|
|
|
|
import com.muyu.common.Result;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
|
/**
|
|
* @author DongZeLiang
|
|
* @version 1.0
|
|
* @description 异常类
|
|
* @date 2023/11/15
|
|
*/
|
|
@RestControllerAdvice
|
|
public class ExceptionAdvice {
|
|
|
|
/**
|
|
* 运行时异常拦截
|
|
* @param runtimeException 运行时异常
|
|
* @return 公共返回结果
|
|
*/
|
|
@ExceptionHandler(value = RuntimeException.class)
|
|
public Result<String> runtimeExceptionHandler(RuntimeException runtimeException){
|
|
return Result.error(runtimeException.getMessage());
|
|
}
|
|
}
|