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失败,请从新发起申请");
            }
        }
    }
  • 相关阅读:
    分布式系统简介
    java.lang.Object 之 clone() 深拷贝,浅拷贝
    粉丝裂变活动bug
    遇到的bug
    移动端fixed定位在底部,出现键盘后消失
    窗口关闭,打开新页面,刷新等总结
    input 手机数字键盘
    正则重温(学习笔记)
    input的表单验证(不断更新中~~)
    css 不大常见的属性(不断更新中...)
  • 原文地址:https://www.cnblogs.com/xianz666/p/13414027.html
Copyright © 2011-2022 走看看