473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

try catch (re)throw problem...

I have an object where I do 'special' cleanup in case of exception
my code is somewhat like that:

void Method()
{
try
{
Something();
}
catch
{
SpecialCleanup();
throw;
}
finally
{
NormalCleanUp();
}
}

my problem is that when an exception is thrown VS break into the catch
clause and I have no idea what causes the exception.

I also tried
catch(Exception ex)
{
SpecialCleanup();
throw ex;
}

but the ex.StackTrace is reinitialized and I have no idea of the problem!
any tips on how to to be able to debug that?

for now I wrote:
#if !DEBUG
catch
{
SpecialCleanup();
throw;
}
#endif

but I would like to catch meaningful stack trace at runtime as well....

Apr 12 '07 #1
2 1496
have you tried catch(Exception ex) and then just "throw" (no ex)?
Apr 12 '07 #2
No, I haven't!
I'll try that tomorrow, thanks!

"Marc Gravell" <ma**********@gmail.comwrote in message
news:u4**************@TK2MSFTNGP03.phx.gbl...
have you tried catch(Exception ex) and then just "throw" (no ex)?

Apr 12 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Arjen | last post by:
Hi, I'm doing this: try { try { } catch(Exception ex){ throw;
4
by: James Radke | last post by:
Hello, I am attempting to use the proper Try/Catch technique when accessing my Microsoft SQL server database and have a question... If I use something similar to the following: Try set up...
3
by: Zerofury | last post by:
I was wondering... you know how java has the ability for us to create a catch throw method for catching and handling exceptions? Is there a way to write this once and have it apply to the entire...
28
by: gnuist006 | last post by:
I have some code like this: (if (test) (exit) (do something)) or (if (test)
3
by: aemado | last post by:
I am really new to the try/catch/throw concept, and can't figure out what is wrong with my code. Any suggestions? #include <iostream> using namespace std; string msgZero = "Zero...
1
by: aemado | last post by:
I am trying to read in several lines, each should have exactly 5 pieces of data. I am using try/catch/throw to determine if the data is in the correct format, and trying to use iss to separate the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.