我有以下密码:
// How to throw the ServerException?
public void myFunc() throws ServerException{
// Some code
CompletableFuture<A> a = CompletableFuture.supplyAsync(() -> {
try {
return someObj.someFunc();
} catch(ServerException ex) {
// throw ex; gives an error here.
}
}));
// Some code
}
抛出一个 ServerException
。我不想在这里处理这个问题,但是抛出从 someFunc()
到 myFunc()
调用者的异常。