我正在寻找有关如何在一个场景中处理 java 中的异常的建议,其中
Class A.test()
{
ClassB.test1()
}
test1()
{
Map listOfExceptions = new HashMap();
for()
{
try{
}
catch(custException e){
// I want the for loop to continue even if there is an exception
//So I am not throughing now rather adding the exception message to map with
//the field name for which for loop is running as key and message as value
{
}
// at some point if map has >0 records I want to throw an exception to classA.
}
所以这里的问题是如何将地图数据添加到抛出的异常中?基本上我需要将异常列表发送到调用方法,作为异常处理的一部分。有没有办法我们可以做到这一点?如果答案众所周知,这可能是一个非常愚蠢的问题,但我无法在任何地方找到确切的答案。