I have a function
public ShoppingCart fetchCart(Long storeId) throw NotFoundException {
///
}
Then I was trying to assign this function to another one by using
Function<Long, ShoppingCart> func = e -> {
fetchCart(e)
}
But it always telling me that the exception is not handled. But when I tried to add try/catch around the function assignment, then my "Function<Long, ShoppingCart> func" is not getting the exception.
Is there a way to do this and also capture the original function's exception? Thanks!
Some more context. I'm doing this since I want the func to be given to another function as parameter so this func can another one can be run in parallel... like compare the values of these functions even their exceptions. Thus the function is essential to be captured not in fetchCart..