package com.huiju.foyo.exception;

import com.huiju.foyo.common.ResponseBean;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

@ControllerAdvice
public class ExceptionHandle {

    @ExceptionHandler(Exception.class)
    public ResponseBean handleError(Exception e){
        ResponseBean responseBean = new ResponseBean();
        responseBean.addError("系统异常");
        return responseBean;
    }

    @ExceptionHandler(FoyoException.class)
    public ResponseBean handleError(FoyoException e){
        ResponseBean responseBean = new ResponseBean();
        responseBean.addError(e.getMessage());
        return responseBean;
    }

}
