dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: .NET
Expertise: Intermediate
Jul 30, 2018

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Use the ExceptionDispatchInfo Class to Capture the Entire Exception

The ExceptionDispatchInfo class can be found in System.Runtime.ExceptionServices namespace and is used to capture an exception that occurs at a point, and it can be thrown later using the ExceotionDispatchInfo.Throw method.

See below for an example.

ExceptionDispatchInfo exceptionDispatchInfo = null;  
try 
{
     //code that throws error 
} 
catch (Exception ex) 
{     
     exceptionDispatchInfo = ExceptionDispatchInfo.Capture(ex); 
}

At a later point in time, you could use the Throw method to throw it, exceptionDispatchInfo.Throw();

Srinath M S
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date