package com.tofly.third.config;

import com.tofly.third.common.exception.BusinessException;
import com.tofly.third.common.res.ResultRespone;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public ResultRespone<Void> businessHandle(BusinessException e) {
        log.error("业务异常 =====================> ", e);
        return ResultRespone.failed(null, "业务异常:" + e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResultRespone<Void> exceptionHandle(Exception e) {
        log.error("系统异常 =====================> ", e);
        return ResultRespone.failed(null, "系统异常:" + e.getMessage());
    }

}
