-1
以下のコードでは、私はIPを取っており、コマンドに応じてGET要求を戻しています。 GETリクエストの中には、別のGETリクエストで同じURLにアクセスできる数字の修飾語があります。プログラムがハングしないようにこれらの修飾子が有効であることを確認する良い方法は何ですか?コンソールアプリケーションでのエラー処理
public class UrlTanslatorInstance {
public String ip;
public UrlTanslatorInstance(String ip){
this.ip = ip;
}
public String translate(String command, String modifier) throws MalformedURLException, IOException{
String url;
switch (command.toUpperCase()){
case "LEFT":
return "http://" + ip + "keypress/left";
case "RIGHT":
return "http://" + ip + "keypress/right";
case "KEYUP":
return "http://" + ip + "keyup/" + modifier;
case "KEYDOWN":
return "http://" + ip + "keydown/" + modifier;
case "KEYPRESS":
return "http://" + ip + "keypress/" + modifier;
case "APPIDS":
return "http://" + ip + "query/apps";
case "LAUNCH":
return "http://" + ip + "keypress/left";
case "ACTIVEAPP":
return "http://" + ip + "query/active-app";
}
return "Command Not Valid";
}
}
いいえ、申し訳ありません。私が言いたいことは、無効な修飾子が使用され、HTTPリクエストが永久にハングしてしまうことです。無効な修飾子は、サーバーから取得可能なIDのセットによって決まります。 –