source\server\model\players\packets\Commands.java:51: error:
unreported exception Exception; must be caught or declared to be thrown
sender.send(Config.PHONE_NUMBER, "Test!");
^
这就是说错误的地方。这就是我的命令。
if (playerCommand.equalsIgnoreCase("smstest")) {
SmsNotification sender = new SmsNotification(Config.GMAIL_USERNAME, Config.GMAIL_PASSWORD, SmsNotification.Carrier.ATT);
sender.send(Config.PHONE_NUMBER, "Test!");
}
现在我想它也可能在我的ShutDownHook中,因为那是我的try,catch语句。这也是这一行。
try {
SmsNotification sender = new SmsNotification(Config.GMAIL_USERNAME, Config.GMAIL_PASSWORD, SmsNotification.Carrier.ATT);
sender.send(Config.PHONE_NUMBER, "A fatal server error has occured!");
System.out.println("\tSuccesfully dispatched SMS notification!");
} catch (Exception e) {
System.out.println("\tFailed to dispatch SMS notification. \""+e+"\"");
}
答案 0 :(得分:-1)
基本上send
方法会抛出异常。
您编写的send
方法会抛出某种异常。所以你需要调用send
方法的地方要么捕获该异常,要么抛出异常传播。
尝试这样做会解决您的错误。