| | |
catch without try
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2009
Posts: 6
Reputation:
Solved Threads: 0
Can anyone shed some light on these errors?
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 ) {}
Java Syntax (Toggle Plain Text)
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 ) {}
•
•
Join Date: Sep 2009
Posts: 26
Reputation:
Solved Threads: 2
1
#4 Nov 5th, 2009
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.
![]() |
Similar Threads
- 'catch' without 'try' (Java)
- How to catch Datagrid error (C#)
- catch and throw (C#)
- problem - one catch block to other catch block of same try block (C)
- try catch and finnaly (Java)
Other Threads in the Java Forum
- Previous Thread: simple question about my code
- Next Thread: need help with some coding
Views: 212 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addressbook android api append apple applet application arguments array arrays automation binary bluetooth character chat class classes client code component csv database draw eclipse error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me japplet java javaarraylist javaprojects jmf jni jpanel julia linked linux list loop map method methods mobile netbeans newbie number object objects oracle oriented panel print printf problem program programming project projects recursion replaydirector reporting researchinmotion return robot rotatetext scanner screen se server set size sms socket sort sql stream string swing test threads time transfer tree ubuntu windows






