我有一段代码:
private void handleReceivedMessage(String m) throws IOException {
switch(m) {
case "ping":
// code block
ping();
break;
default:
System.out.println("message not understood");
}
}
public DataServer(int port) throws IOException {
server = new Server(port, this::handleReceivedMessage);
server.acceptClient();
}现在,我在以下一行得到了错误::handleReceivedMessage: java.io.IOException :java.io.IOException
我该怎么解决这个问题?很明显,handleReceivedMessage函数确实抛出了一个IOException
发布于 2022-05-31 11:23:26
在不了解更多信息的情况下,我会尝试使用try/catch语句专门捕获Olivier建议抛出的异常。如果我可以问一下,为什么不使用try/catch来检查错误呢?
https://stackoverflow.com/questions/72446809
复制相似问题