Re: Variables in catch(...) clauses?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 02/26/04


Date: Thu, 26 Feb 2004 13:45:27 -0000

Me2 <r@r.com> wrote:
> I have taken and passed the Web and Windows coding exams and I don't
> remember any questions that dealt with whether the exception variable should
> or should not be used. I agree with you that if you are not going to
> inspect the exception codes that are passed back, then why include the
> variable. Would omitting the variable cause the resulting IL code to
> execute faster or slower?

The IL generated when there's no variable just pops the exception off
the stack. Basically, I expect there'll be no significant difference in
execution speed.

> As far as having the explicit catch clauses for exceptions, you should have
> the catch "all" after the specific tested exceptions in case something bombs
> that you did not expect.

Only if you actually *want* to catch everything, which you often don't
want to. You may well have a couple of places in the whole code where
you want to catch everything, but many other places where you want to
only catch specific exceptions.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: Variables in catch(...) clauses?
    ... > I have taken and passed the Web and Windows coding exams and I don't ... > remember any questions that dealt with whether the exception variable should ... > execute faster or slower? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Variables in catch(...) clauses?
    ... I have taken and passed the Web and Windows coding exams and I don't ... remember any questions that dealt with whether the exception variable should ... > correct option is to always declare the exception variable - without any ... > known to test heavily on anything Microsoft strongly recommends). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Variables in catch(...) clauses?
    ... I have taken and passed the Web and Windows coding exams and I don't ... remember any questions that dealt with whether the exception variable should ... > correct option is to always declare the exception variable - without any ... > known to test heavily on anything Microsoft strongly recommends). ...
    (microsoft.public.cert.exam.mcsd)
  • Re: D2005 Code Folding
    ... Potential side effects of a exception is not dealt with inside the subroutine thereby making it less future proof. ...
    (borland.public.delphi.non-technical)
  • [PATCH 5/17] FRV: Support module exception tables
    ... The attached patch fixes the exception table handling so that modules ... exceptions are dealt with. ...
    (Linux-Kernel)