public void saveMultiplexCfgSrc(MultiplexCfgSrc multiplexCfgSrc) 
       {      
          if (multiplexCfgSrc == null) 
           {    
               LOGGER.runtime.error(""); 
                 
               throw new WFException(""); 
          }          if (StringUtils.isBlank(multiplexCfgSrc.getId())) 
             { 
                try 
                 { 
                 multiplexCfgSrcDAO.createMultiplexCfgSrc(multiplexCfgSrc); 
                } 
              catch (BMEException e) 
                 { 
                 LOGGER.runtime.error( 
                         WFELogCodeConst.O_CREATE_MULTIPLEX_CFG_SRC_FAILED, 
                             e, 
                          multiplexCfgSrc.toString()); 
                throw new WFException( 
                         WFEErrorCodeConst.E_CREATE_MULTIPLEX_CFG_SRC_FAILED, e); 
             } 
      
           } 

解决方案 »

  1.   

    不知道 multiplexCfgSrcDAO.createMultiplexCfgSrc(..) 里面的代码如何写的
    只要传一个null就可以报第一个异常!MultiplexCfgSrc multiplexCfgSrc = null;dao.saveMultiplexCfgSrc(multiplexCfgSrc) ;
      

  2.   

    整个代码中易出异常的地方已被用try catch捕获了,若想报异常。
    把代码中的Try块去掉,异常不就出现了吗?
      

  3.   

    try{
    }catch(Exception e) {
    e.printStackTrace();
    }
      

  4.   

    multiplexCfgSrc.getId() = null  就可以出现异常了吧
      

  5.   

    再抛出一个异常就行了,用这个throws关键字!想抛什么异常就抛什么异常!
      

  6.   

    throw new Exception();
      

  7.   

    可能我没说清楚吧 上面这段代码是我不能改的。我现在是写UT,搞覆盖率。我想知道有什么办法可以执行catch里面的语句。 create,update 我有办法让这段代码处异常。但是query delete了。
      

  8.   

    新写一个类继承自MultiplexCfgSrc,除了getId其他都抛这个BMEException 
      

  9.   

    进行debug,watch一下。然后改成异常的值。肯定能抛
      

  10.   

    在 create update 异常我知道,就是让传进去的字符长度大于表字段定义的长度。但查询似乎没用了,如果传null 空串 在前面就会StringUtils.isBlank()时进入错误日志。数据库关键字也不行。而查询要什么什么样的异常值 才能让 multiplexCfgSrcDAO.queryMultiplexCfgSrc(id); 恕我愚昧。我真不知道查询的时候 什么样的id值会是异常值
      

  11.   


    public void saveMultiplexCfgSrc(MultiplexCfgSrc multiplexCfgSrc){
    try {
    if (multiplexCfgSrc == null) {    
    LOGGER.runtime.error("");                  
    throw new WFException(""); 
             }
         if (StringUtils.isBlank(multiplexCfgSrc.getId())){
         multiplexCfgSrcDAO.createMultiplexCfgSrc(multiplexCfgSrc); 
         }
    }catch (BMEException e) { 
    LOGGER.runtime.error( 
                             WFELogCodeConst.O_CREATE_MULTIPLEX_CFG_SRC_FAILED, e, 
                              multiplexCfgSrc.toString()); 
           throw new WFException( 
                             WFEErrorCodeConst.E_CREATE_MULTIPLEX_CFG_SRC_FAILED, e); 
         }