all groups > visual studio .net debugging > september 2007 >
You're in the

visual studio .net debugging

group:

Throw without parameter...


Throw without parameter... AshokG
9/21/2007 12:00:00 AM
visual studio .net debugging:
Hi,

If you use just throw without parameter should preserve the complete stack
trace and the exception information.

for example:

1. private void Bar()
2. {
3. try
4. {
5. string s = null;
6. if (s.Length == 0)
7. return;
8. }
9. catch
10. {
11. // do some processing...
12. throw;
13. }
14. }
15.
16.private void Foo()
17.{
18. try
19. {
20. Bar();
21. }
22. catch (Exception ex)
23. {
24. // do some processing...
25. Console.WriteLine(ex.ToString())
26. }
27.}

In the above code it should show error line nos 6, 12 and 20 in the stack
trace. But now in newer versions it is just showing the line nos. 12 and 20.

It seems this functionality is removed or a bug in newer versions. It's no
longer preserving the stack trace info. I saw this In .NET l.0 framework
(VS.NET 2002).


Regards,
Ashok

Re: Throw without parameter... RB
9/21/2007 12:00:00 AM
[quoted text, click to view]

Java would certainly preserve the stack trace, but I've never known .NET
to do that.

In .NET I tend to use nested exceptions for this functionality as it
will print out the stack trace of the caught exception, and all nested
exceptions.

So, your line 9 -> 13 becomes:

catch (Exception ex)
{
throw new Exception("I'm nesting an exception", ex)
}

Cheers,

Re: Throw without parameter... Frans Bouma [C# MVP]
9/21/2007 1:57:52 AM
[quoted text, click to view]

Isn't there an inner exception in 'ex' in Foo ?

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
Re: Throw without parameter... Cor Ligthert[MVP]
9/21/2007 7:52:49 PM
What a dirty programming style

Cor


"AshokG" <gw2ksoft@hotmail.com> schreef in bericht
news:OefNi3B$HHA.1188@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]
Re: Throw without parameter... Göran_Andersson
9/21/2007 10:28:09 PM
[quoted text, click to view]

I fail to see how that has anything at all to do with the question.

--
Göran Andersson
_____
Re: Throw without parameter... Cor Ligthert[MVP]
9/22/2007 12:00:00 AM

">
[quoted text, click to view]
I fail to see why you are sending this message, the code does not even
compile in VB.Net.

Cor
Re: Throw without parameter... Alberto Poblacion
9/22/2007 12:00:00 AM
[quoted text, click to view]

That's one of the reasons why cross-posting to multiple groups is
discouraged. The original poster sent the message (which contained some code
in C#) to multiple groups, including the VB group, where of course the code
won't even compile.
Re: Throw without parameter... Göran_Andersson
9/22/2007 12:00:00 AM
[quoted text, click to view]

What code? I didn't post any code. You are not making any sense at all.

--
Göran Andersson
_____
AddThis Social Bookmark Button