zoukankan      html  css  js  c++  java
  • java中自定义一个异常类 在某些情况抛出自定的异常 ----------阻断程序

    //=============定义异常类
    package org.springblade.flow.engine.errorException;
    
    
    /**
     * 自定义异常处理写入sap失败
     */
    public class CallbackErrorException extends Exception{
        public CallbackErrorException(String detailMessage) {
            super(detailMessage);
        }
    }
    
    //============= 需要抛出异常的类
    package org.springblade.flow.engine.listener.execution;
    import lombok.SneakyThrows;
    import org.flowable.engine.delegate.DelegateExecution;
    import org.flowable.engine.delegate.ExecutionListener;
    import org.springblade.desk.feign.IBusinessPartnerClient;
    import org.springblade.flow.engine.errorException.CallbackErrorException;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;
    
    /**
     * create by Dell on 2020/7/18
     */
    @Component("businessPartnerExecutionListener")
    public class BusinessPartnerExecutionListener implements ExecutionListener {
    
        @Autowired
        private IBusinessPartnerClient businessPartnerClient ;
    
        @SneakyThrows(CallbackErrorException.class)
        @Override
        public void notify(DelegateExecution execution) {
            String processInstanceId=execution.getProcessInstanceId();
            System.out.println("业务伙伴主数据processInstanceId=============="+processInstanceId);
            boolean msg=businessPartnerClient.businessPartnerCreate(processInstanceId);
            System.out.println("业务伙伴主数据msg=============="+msg);
            if(!msg) {
                throw new CallbackErrorException("写入sap失败,请从新发起申请");
            }
        }
    }
  • 相关阅读:
    前端
    前端
    数据库
    代码块
    装饰器
    函数 初识函数
    相识python --------文件操作
    相识python --------str字符串 int整形 bool布尔值 tu元祖 set()集合 dict 字典的数据补充
    【openstack报错】【因更新包而致】IncompatibleObjectVersion: Version 1.9 of Instance is not supported
    开博第一篇
  • 原文地址:https://www.cnblogs.com/xianz666/p/13414027.html
Copyright © 2011-2022 走看看