Can anyone shed some light on these errors?

public void FaultHandler () {
		int faultCount = 0;
	 while ( faultCount < 4 ) {
		  DatagramPacket request =
			  new DatagramPacket(requestArray, requestArray.length, aHost, proxyPort);	
		  aSocket.send(request);	
	 try {
		  aSocket.setSoTimeout(4000);
		  aSocket.receive(reply);
	      }
	 catch ( SocketTimeoutException e ) {
		  faultCount++;
		  continue; 
	      }
	 catch ( IOException e ){}
		 break;
	      
	 catch ( IOException e ) {}	  //----it doesn't like this line!
	      if ( faultCount >= 3 )
	      System.exit(0);
	      }
	}

I keep getting these errors:

'catch' without 'try'
catch ( IOException e ) {}
^
Ex2Client.java:18: ')' expected
catch ( IOException e ) {}
^
Ex2Client.java:18: not a statement
catch ( IOException e ) {}
^
Ex2Client.java:18: ';' expected
catch ( IOException e ) {}

The "break" on line 16 is outside any catch, so it terminates the list of catches associated with the previous try. So the catch on line 18 hasn't got a try to match to.

In addition to the "break" comment above, which is dead-on, you also can't catch the same exception twice in a try clause...you're catching IOException a second time after the break.

This article has been dead for over six months. Start a new discussion instead.