我在主线程中得到异常......即使我处理异常

1 java exception

public KalaGame(KeyBoardPlayer player1,KeyBoardPlayer player2)
 {   //super(0);
 int key=0;
 try
 {

     do{
     System.out.println("Enter the number of stones to play with: ");

      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  
        key = Integer.parseInt(br.readLine());  


    if(key<0 || key>10)
  throw new InvalidStartingStonesException(key);
  }
 while(key<0 || key>10);
    player1=new KeyBoardPlayer();
   player2 = new KeyBoardPlayer(); 
   this.player1=player1;
   this.player2=player2;
   state=new KalaGameState(key);



 }


    catch(IOException  e)
    {
       System.out.println(e);
      }
     } 
Run Code Online (Sandbox Code Playgroud)

当我输入无效数量的宝石时,我收到此错误

线程"main"中的异常InvalidStartingStonesException:起始宝石的数量必须大于0且小于或等于10(尝试22)

为什么不是由我定义的throw处理的异常

KalaGame.<init>(KalaGame.java:27) at PlayKala.main(PlayKala.java:10)

Ant*_*ney 5

你只处理一个IOException但不是被抛出的异常,即一个InvalidStartingStonesException.