java 6

问题描述

我在一个使用 java 6 的系统中工作。 我已经实现了一个读取 xml 文件、解析它并将数据保存在 DB 中的组件。 实现如下所示。

void importXMLFiles() throws ImportFailedException
 {
   LOGGER.info("Started importing XML files.");
   try
   {
     xmlImportHandler.importData(getXMLData());
     LOGGER.info("Successfully imported XML files.");
   }
   catch (ImportHandlerNotFoundException e)
   {
     LOGGER.error("Importing XML files Failed Due to an unexpected error.");
     throw new ImportFailedException(e.getMessage(),e);
   }
   catch (XMLFileCannotBeReadException e)
   {
     LOGGER.error("Importing XML files Failed Due to an unexpected error.");
     throw new ImportFailedException(e.getMessage(),e);
   }
   catch (XMLFileNotFoundException e)
   {
     LOGGER.error("Importing XML files Failed Due to an unexpected error.");
     throw new ImportFailedException(e.getMessage(),e);
   }
   catch (XMLConfigurationsMissingException e)
   {
     LOGGER.error("Importing XML files Failed Due to an unexpected error.");
     throw new ImportFailedException(e.getMessage(),e);
   }
 }

方法调用执行多项任务的其他几个组件。这些方法抛出不同的异常。我在这方法中捕获了所有这些并抛出一个常见的异常。但看起来我需要在此方法中捕获更多异常。所有的 catch 块都做同样的事情。我觉得这不是一个好的设计。

在 Java 6 中是否有更好的方法/模式来处理此类场景中的异常?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...