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失败,请从新发起申请");
            }
        }
    }
  • 相关阅读:
    sass安装与使用
    前端兼容性问题
    springboot项目数据库错误记录
    C#实现微信聊天对话框
    关于html的多行匹配,正则re.S的使用(爬取豆瓣电影短评)
    判断网页能否打开?python
    利用python爬取点小图片,满足私欲(爬虫)
    ajax加载时的进度条
    java 发送微信客服消息
    Fastjson Mysql JDBC 反序列化
  • 原文地址:https://www.cnblogs.com/xianz666/p/13414027.html
Copyright © 2011-2022 走看看