Exception specs are bad because they're weakly enforced, and therefore don't actually accomplish much, and they're also bad because they force the run-time to check for unexpected exceptions so that they can terminate(), instead of invoking UB, this can waste a significant amount of performance.
So in summary, exception specs aren't enforced strongly enough in the language to actually make code any safer, and implementing them as specified was a big performance drain.
I've been through a very similar situation when I had to deal with a terrible legacy Windows Forms code written by developers that clearly didn't know what they were doing.
First of all, you're not overacting. This is bad code. Like you said, the catch block should be about aborting and preparing to stop. It's not time to create objects (specially Panels). I can't even start explaining why this is bad.
That being said...
My first advice is: if it's not broken, don't touch it!
If your job is to maintain the code you have to do your best not to break it. I know it's painful (I've been there) but you have to do your best not to break what is already working.
My second advice is: if you have to add more features, try keeping the existing code structure as much as possible so you don't break the code.
Example: if there's a hideous switch-case statement that you feel could be replaced by proper inheritance, you must be careful and think twice before you decide to start moving things around.
You will definitely find situations where a refactoring is the right approach but beware: refactoring code is more likely to introduce bugs. You have to make that decision from the application owners perspective, not from the developer perspective. So you have to think if the effort (money) necessary to fix the problem is worth a refactoring or not. I've seen many times a developer spending several days fixing something that is not really broken just because he thinks "the code is ugly".
My third advice is: you will get burned if you break the code, it doesn't matter if it's your fault or not.
If you've been hired to give maintenance it doesn't really matter if the application is falling apart because somebody else made bad decisions. From the user perspective it was working before and now you broke it. You broke it!
Joel puts very well in his article explaining several reasons why you should not rewrite legacy code.
http://www.joelonsoftware.com/articles/fog0000000069.html
So you should feel really bad about that kind of code (and you should never write anything like that) but maintaining it is a whole different monster.
About my experience: I had to maintain the code for about 1 year and eventually I was able to rewrite it from scratch but not all at once.
What happened is that the code was so bad that new features were impossible to implement. The existing application had serious performance and usability issues. Eventually I was asked to make a change that would take me 3-4 months (mostly because working with that code took me way more time than usual). I thought I could rewrite that whole piece (including implementing the desired new feature) in about 5-6 months. I brought this proposition to the stakeholders and they agree to rewrite it (luckily for me).
After I rewrote this piece they understood I could deliver much better stuff than what they already had. So I was able to rewrite the entire application.
My approach was to rewrite it piece by piece. First I replaced the entire UI (Windows Forms), then I started to replace the communication layer (Web Service calls) and last I replaced the entire Server implementation (it was a thick client / server kind of application).
A couple years later and this application has turned into a beautiful key tool used by the entire company. I'm 100% sure that would've never been possible had I not rewritten the whole thing.
Even though I was able to do it the important part is that the stakeholders approved it and I was able to convince them it was worth the money. So while you have to maintain the existing application just do your best not to break anything and if you're able to convince the owners about the benefit of rewriting it then try to do it like Jack the Ripper: by pieces.
Best Answer
IMO, they're included in Java and C# primarily because they already existed in C++. The real question, then, is why is C++ that way. According to The Design and Evolution of C++ (ยง16.3):
Edit: As to why this would be confusing, I think one has only to look at the incorrect assertions in @Tom Jeffery's answer (and, especially, the number of up-votes it has received) to realize that there would be a problem. To the parser, this is really no different from matching
else
s withif
s -- lacking braces to force other grouping, allcatch
clauses would match up with the most recentthrow
. For those misbegotten languags that include it,finally
clauses would do the same. From the viewpoint of the parser, this is hardly enough different from the current situation to notice -- in particular, as the grammars stand now, there's really nothing to group thecatch
clauses together -- the brackets group the statements controlled by thecatch
clauses, not the catch clauses themselves.From the viewpoint of writing a parser, the difference is almost too tiny to notice. If we start with something like this:
Then the difference would be between:
and:
Likewise, for catch clauses:
vs.
The definition of a complete try/catch block would not need to change at all though. Either way it would be something like:
[Here I'm using
[whatever]
to indicate something optional, and I'm leaving out the syntax for afinally_clause
since I don't think it has any bearing on the question.]Even if you don't try to follow all the Yacc-like grammar definition there, the point can be summarized fairly easily: that last statement (starting with
try_block
) is the one wherecatch
clauses get matched up withtry
clauses -- and it remains exactly the same whether the braces are required or not.To reiterate/summarize: the braces group together the statements controlled by the
catch
s, but do not group thecatch
s themselves. As such, those braces have absolutely no effect upon deciding whichcatch
goes with whichtry
. For the parser/compiler the task is equally easy (or difficult) either way. Despite this, @Tom's answer (and the number of up-votes it's received) provides ample demonstration of the fact that such a change would almost certainly confuse users.