0
我在下面的代码中找到异常处理的代码,该异常处理处理包括运行时在内的应用程序抛出的所有可执行文件。通用异常处理
public static void handleException(String strMethodName,
Exception ex) throws CustomException{
String strMessage = "";
try {
throw ex;
}
catch (NullPointerException npe){
logger.log(pr, strMethodName, npe.getMessage());
strMessage=ERR_02;
throw new CustomException(strMessage);
}
catch(IndexOutOfBoundsException iobe) {
logger.logMethodException(strMethodName,iobe.getMessage());
strMessage=ERR_03;
throw new CustomException(strMessage);
}
... So On
}
下面是一些我认为不足之处:
- 要idenitify我们将需要经常检查的消息字符串异常的根本原因。
- 更少的代码:
- 型异常
优势的无sepearation。 (代码可以最小化)
请您告诉我是否应该使用这种机制。