Sigh



  • <FONT size=2></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>catch</FONT></FONT><FONT size=2> (</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Exception</FONT></FONT><FONT size=2> ex)</FONT></FONT><FONT size=2>

    {

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>throw</FONT></FONT><FONT size=2>;</FONT></FONT><FONT size=2>

    }

    </FONT>


  • Could be used as a breakpoint.

    davidh



  • Yes, or they had some code in there that they removed later, for writing to a log file or whatever.



  • let me guess, you only posted this to make it look like you know better.

    There could have been something in the finally that they wanted to make sure would run.  The only way to do this even when you don't want to handle the exception directly is to have a catch that simply throws.

    For example:

            Dim x As Integer
            Dim y As Integer
            Dim z As Double

            Try
                x = 1
                y = 0
                z = x \ y

            Catch ex As Exception
                Throw
            Finally
                MessageBox.Show("Made it here.")
            End Try

     



  • @KattMan said:

    let me guess, you only posted this to make it look like you know better.

    There could have been something in the finally that they wanted to make sure would run.  The only way to do this even when you don't want to handle the exception directly is to have a catch that simply throws.

    For example: <snip>

    Well, neither Java nor VB .NET (nor the CIL) require a catch as part of a try. You must have at least one catch, finally, or fault block, but you don't need one of each and none of them individually is required. My guess is that
    								        psiphiorg is right and they were using it as a possible breakpoint location, or that they were trying to stop stack frame elision (which wouldn't actually work if you did that). </p>


  • @TwelveBaud said:

    @KattMan said:

    let me guess, you only posted this to make it look like you know better.

    There could have been something in the finally that they wanted to make sure would run.  The only way to do this even when you don't want to handle the exception directly is to have a catch that simply throws.

    For example: <snip>

    Well, neither Java nor VB .NET (nor the CIL) require a catch as part of a try. You must have at least one catch, finally, or fault block, but you don't need one of each and none of them individually is required. My guess is that
    								        psiphiorg is right and they were using it as a possible breakpoint location, or that they were trying to stop stack frame elision (which wouldn't actually work if you did that). </p><p></blockquote>&nbsp;</p><p>Or they could have thought the same thing as KattMan in which case it is a (minor) WTF. <br></p>


  • @KattMan said:

    let me guess, you only posted this to make it look like you know better.

    Isn't that the entire point of posting a thread here?



  • Sigh indeed. I wish people would at least attempt to say something about the WTF in the subject.



  • Better version:

    <FONT color="#0000ff">catch</FONT>
    {
        <FONT color="#0000ff">throw</FONT>;
    }

    Worse version:

    <FONT color="#0000ff">catch</FONT> (<FONT color="#2b91af">Exception</FONT> ex)
    {
        <FONT color="#0000ff">throw</FONT> ex;
    }

    Best version:



  • @KattMan said:

    let me guess, you only posted this to make it look like you know better.

    There could have been something in the finally that they wanted to make sure would run.  The only way to do this even when you don't want to handle the exception directly is to have a catch that simply throws.

    For example:

            Dim x As Integer
            Dim y As Integer
            Dim z As Double

            Try
                x = 1
                y = 0
                z = x \ y

            Catch ex As Exception
                Throw
            Finally
                MessageBox.Show("Made it here.")
            End Try

     

     

    Um, no.



  • @campkev said:

    <font size="2"><font color="#0000ff">catch</font> (<font color="#2b91af">Exception</font> ex)

    {

    <font color="#0000ff">throw</font>;

    }

    </font>

    That reminds me of one of the earlier examples of Java code I've seen.  Except that it did that in nearly every fricking method. Also, it did indents:

        <font color="#0000ff">catch</font> (<font color="#2b91af">Exception</font> ex) 
        {
            <font color="#0000ff">throw</font>; 
        }
    

Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.