在实现类中,抛出对应的异常

    1. 抛出方式

    throw new ApiException(CodeEnum.TOKEN_EXPIRE);

    1. 异常判断。

    在切面类中,异常类型判断。

    @AfterThrowing(value = “within(cn.**.api.identity.controller..*)”,throwing=”e”)
    public void afterThrowing(Exception e) {

    if(e instanceof ExpiredJwtException){
    return;
    }
    if(e instanceof ExpiredJwtException){
    return;
    }
    if (e instanceof ApiException) {
    msg = ((ApiException) e).getResult().getMsg();
    tradeNo = ((ApiException) e).getResult().getTradeNo();
    /*扣费/
    _serviceLog.setStatus(Constants.ServiceLog._STATUS_1);/**日志标位扣费状态/
    _csService.reduce();
    _log
    .error(“【{}】返回参数:{}”,tradeNo,((ApiException) e).getResult());
    }
    if (e instanceof BankCardOverLimitedException) {
    msg = ((BankCardOverLimitedException) e).getResult().getMsg();
    tradeNo = ((BankCardOverLimitedException) e).getResult().getTradeNo();
    log.error(“【{}】返回参数:{}”,tradeNo,((BankCardOverLimitedException) e).getResult());
    }
    if (e instanceof FaceErrorException) {
    msg = ((FaceErrorException) e).getResult().getMsg();
    tradeNo = ((FaceErrorException) e).getResult().getTradeNo();
    log.error(“【{}】返回参数:{}”,tradeNo,((FaceErrorException) e).getResult());
    }
    if (e instanceof ParameterErrorException) {
    msg = ((ParameterErrorException) e).getResult().getMsg();
    tradeNo = ((ParameterErrorException) e).getResult().getTradeNo();
    log.error(“【{}】返回参数:{}”,tradeNo,((ParameterErrorException) e).getResult());
    }
    if (e instanceof BeforeApiException) {
    msg = ((BeforeApiException) e).getResult().getMsg();
    tradeNo = ((BeforeApiException) e).getResult().getTradeNo();
    log.error(“【{}】返回参数:{}”,tradeNo,((BeforeApiException) e).getResult());
    }