package com.caimei.www.config;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import reactor.core.publisher.Mono;

/**
 * 统一异常处理
 *
 * @author : Charles
 * @date : 2020/8/7
 */
@RestControllerAdvice
public class CustomExceptionHandler {

    @ExceptionHandler(Exception.class)
    public String convertExceptionMsg(Exception e) {
        //自定义逻辑，可返回其他值
        e.printStackTrace();
        return "404";
    }

    @ExceptionHandler(IllegalAccessException.class)
    public Mono<String> convertIllegalAccessError(Exception e) {
        //自定义逻辑，可返回其他值
        return Mono.just("illegal access");
    }
}
