Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 26th, 2007, 12:58 PM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to surendraparashar
Default cach(Exception e)

Please anyone clear the difference between the following statements


cach(Exception e)
{
  throw e;
}


and


cach(Exception e)
{
  throw;
}


Surendra
__________________
Surendra Parashar
Gurgaon,
http://www.geocities.com/surendraparashar
 
Old June 26th, 2007, 01:38 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

throw e basically destroys the call stack, while throw maintains it. throw essentially forwards the current exception.

Unless you want to erase previous stack trace and exception information, you should use throw instead of throw e.

Use throw e only when you're creating a new exception that optionally wraps the original e. E.g.

throw new YourOwnAppException("Something went terribly wrong", e);

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old June 26th, 2007, 05:03 PM
Authorized User
 
Join Date: Dec 2005
Posts: 28
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to surendraparashar
Default

Thanks
:)

Surendra





Similar Threads
Thread Thread Starter Forum Replies Last Post
COM Exception muralidharan.d VS.NET 2002/2003 0 August 7th, 2007 02:49 PM
Article-Object Query Language for Distributed Cach sarosh Classic ASP Databases 0 May 14th, 2007 07:21 AM
Un Authorized Exception ashokparchuri XML 1 December 9th, 2006 10:50 AM
Exception Ochi C# 1 January 15th, 2006 11:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.