無法在try/catch block
中包裝流對象。Java:捕捉lambda異常
我想是這樣的:
reponseNodes.stream().parallel().collect(Collectors.toMap(responseNode -> responseNode.getLabel(), responseNode -> processImage(responseNode)));
啓動Eclipse抱怨強調processImage(responseNode)
和建議,它需要Surround with try/catch
。
然後我更新爲:
return reponseNodes.stream().parallel().collect(Collectors.toMap(responseNode -> responseNode.getLabel(), responseNode -> try { processImage(responseNode) } catch (Exception e) { throw new UncheckedException(e); }));
更新代碼也沒有工作。
您可以輸入Eclipse提供給您的確切警告/錯誤嗎? –
Eclipse警告'環繞着try/catch'強調'processImage(responseNode)'。 –