在 try catch 块中获取未处理的异常 java
getting unhandled exception in try catch block java
我在我的代码中添加了 try catch 块,尽管我收到编译时错误提示未处理的异常。
try {
aList.stream.forEach(a->bList.addAll(getAValues(a)));
}catch(CustomizedException e){
log.debug(e.getMessage());
}
getAValues(String a) 方法抛出相同的 "CustomizedException"。但仍然遇到未处理的异常。
getAValues(String a) throws CustomizedException {
//some code
}
需要在您的 lambda 表达式正文中捕获异常
aList.stream.forEach(a -> {
try {
bList.addAll(getAValues(a))
} catch(CustomizedException cex) {
// handle it
}
});
我在我的代码中添加了 try catch 块,尽管我收到编译时错误提示未处理的异常。
try {
aList.stream.forEach(a->bList.addAll(getAValues(a)));
}catch(CustomizedException e){
log.debug(e.getMessage());
}
getAValues(String a) 方法抛出相同的 "CustomizedException"。但仍然遇到未处理的异常。
getAValues(String a) throws CustomizedException {
//some code
}
需要在您的 lambda 表达式正文中捕获异常
aList.stream.forEach(a -> {
try {
bList.addAll(getAValues(a))
} catch(CustomizedException cex) {
// handle it
}
});