| | |
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 30 Days Ago
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
| Thread Tools | Search this Thread |
actuate android api applet application applications array arrays automation balls bank binary bluetooth business chat class classes clear client code codesnippet collections component database defaultmethod development dice dragging ebook eclipse error event exception formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide image infinite input integer intersect invokingapacheantprogrammatically j2me java javaprojects jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie numbers openjavafx parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads time tree windows






