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失败,请从新发起申请");
            }
        }
    }
  • 相关阅读:
    jquery load 方法回显数据
    jquery动态添加表单数据
    表单对象属性disabled和readOnly
    jQuery 对象和 DOM 对象
    jQuery 回调函数
    JQuery与JavaScript onload的区别
    BigDecimal类型数据保留两位小数即百分比运算
    一次SQL查询语句的优化
    富文本编辑器的保存操作注意事项
    poi 技术动态更新 Excel模板内容,动态更新内容
  • 原文地址:https://www.cnblogs.com/xianz666/p/13414027.html
Copyright © 2011-2022 走看看