Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Throw Exception Vs Throw New Exception (http://www.velocityreviews.com/forums/t65216-throw-exception-vs-throw-new-exception.html)

Kerri 10-27-2003 11:01 AM

Throw Exception Vs Throw New Exception
 
Hi,

I am new to .NET

In my Error Logic on my Aspx pages when an error happens
it hits my catch statement where I throw an Exception.

My question is :

what is the difference between Thwo Exception and Throw
New Exception?

Anq when should either be used?

Thanks,
Kerri.

Ravikanth[MVP] 10-27-2003 01:13 PM

Throw Exception Vs Throw New Exception
 
Hi


Below are 3 most common ways exceptions are thrown from
within a method.

*1 - If the method that is called throws an exception
which is not caught within that method then caller method
gets the Exception.

*2 - Some operations may also throw exceptions, as shown
above i/j will throw an exception if value of j is 0.

*3 - If in our method code we encounter a condition which
needs to be notified in form of an exception then we can
throw an exception by using throw statement. We create a
new instance of Exception based class and throw it. Later
on we will discover how we can have our own exception
classes and load them with desired information.



HTH
Ravikanth[MVP]


>-----Original Message-----
>Hi,
>
>I am new to .NET
>
>In my Error Logic on my Aspx pages when an error happens
>it hits my catch statement where I throw an Exception.
>
>My question is :
>
>what is the difference between Thwo Exception and Throw
>New Exception?
>
>Anq when should either be used?
>
>Thanks,
>Kerri.
>.
>


Kevin Spencer 10-27-2003 02:13 PM

Re: Throw Exception Vs Throw New Exception
 
"Exception" is a type. "New Exception()" is an instance of a class (type).
It's the difference between, for example, saying "Throw Integer" versus
"Throw 6." One is a type, and defines the characteristics of any instance of
that type. The other is an actual instance of a type.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Kerri" <anonymous@discussions.microsoft.com> wrote in message
news:06ca01c39c79$afab4980$a101280a@phx.gbl...
> Hi,
>
> I am new to .NET
>
> In my Error Logic on my Aspx pages when an error happens
> it hits my catch statement where I throw an Exception.
>
> My question is :
>
> what is the difference between Thwo Exception and Throw
> New Exception?
>
> Anq when should either be used?
>
> Thanks,
> Kerri.





All times are GMT. The time now is 08:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.