Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Back to VSLive! San Francisco Show Daily Home

email article
printer friendly

When to Use Throw vs. Throw ex
Learn how to avoid VB code mishaps such as this one.
by Jackie Goldstein

VSLive! San Francisco, February 8, 2005

Note: Jackie Goldstein is presenting "VB Worst Practices" at VBITS San Francisco, Wednesday, February 9. This tip is from that session.

Writing code that is syntactically correct is just the beginning of writing good VB code. Here's an example.

If you want to rethrow or propagate an error that you have just caught, be sure to write

   Throw

rather than

   Throw ex 

Throw (by itself) will throw the error that it just caught. Throw ex will wipe out all the stack frame information and make it seem like the error occurred on the line of the Throw ex, instead of where it actually occurred.

About the Author
Jackie Goldstein has achieved national and international recognition for expertise in Windows and .NET development in general, and Visual Basic and database applications in particular. He is the principal of Renaissance Computer Systems Ltd., which specializes in consulting, training, and development with Microsoft tools and technologies.



Back to top










Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home