1

I saw some codes here in the application I'm working with:

 Try //Some code Catch ex As Exception Throw ex End Try 

I wonder why do they have to throw the exception that they caught? I don't get it. Well, I don't have any contacts to the developer of this app that's why I'm asking here.

Thanks in advance!

4
  • According to syntax of Try Catch they will do so. Commented Oct 20, 2011 at 9:51
  • But why? I think it's nonsense. Catch and throw? Why? Commented Oct 20, 2011 at 9:53
  • I can only think of 1 reason why he made this code.. Some methods/objects need to be defined inside a trycatch, but maybe he wanted to let the program crash for debug purposes? If you don't create the try/catch you can't build it.. Commented Oct 20, 2011 at 9:54
  • 1
    It's impossible to know "why" he did it. Perhaps he intended to handle it differently and this was just temporary filler code. Perhaps he didn't know any better. Commented Oct 20, 2011 at 10:14

1 Answer 1

3

I can think of two reasons:

  • There have been, or the author has planned for, additional code before the throw.
  • Debugging purposes. The code doesn't do anything as it stands now, but it allows for a breakpoint to be placed on the throw statement.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.