Why is catch block executed twice for a single exception?

exception, java, swing

Solution

You've left open the obvious possibility that one of the lines of code after the success dialog is displayed is throwing an exception. You're not catching a specific exception and you're not displaying a backtrace, so there's no way of telling. Start your debugging by using the caught exception's `printStackTrace` method to find out where it's coming from.

Problem

I have the following code. ``` try{ Twitter twitter = new Twitter(user,password); twitter.setStatus(txtStatus.getText()); JOptionPane.showMessageDialog(null, "Success"); txtStatus.setText(""); txtStatus.requestFocus(); }catch(Exception e){ JOptionPane.showMessageDialog(null, "Some Error.\n" + " If you see this after Success Message..Ignore"); } ``` Here even after I get "Success message" Dialog, the "Some Error" dialog is also appearing. what may be the reason? Shouldnt the flow control escape the catch block if there were no run time errors. Even if i get an exception also, the "Some Error" dialog is appearing twice.Why is this happenning?

Original source