Is it the same when I use this:
catch(Exception e)
{
throw new Exception("some Exception", e);
}
and this:
catch(Exception e)
{
throw new Exception("some Exception", e.InnerException);
}
or Di I am missing something?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your second example you are discarding the caught exception and are using its inner exception instead. You would normally code as you have in the first example.
In the first case, the caught exception (
e) becomes theInnerExceptionof the new exception you are throwing:In the second case you are using the
InnerExceptionofe, and the data fromeis lost: