Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ShlomiSteinberg

Gathering Exception Data

This topic is 5568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When an exception occurs in my program I would like to know EXCATLY where it occurred and what exactly happend. I don''t want to do a __try __except statment for every line in my engine. I want to know the file name, line number and what happend there. Is it possible? "C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
Advertisement
Assuming C++, you can use the __FILE__ and __LINE__ preprocessor macros (I think they are standard, though I have only used them in MSVC 6). They expand to standard C-style strings (null-terminated arrays of characters) with the file name and line number.

[edited by - GrinningGator on August 18, 2003 7:40:36 PM]

Share this post


Link to post
Share on other sites
according to MSDN:
__DATE__, __FILE__, __LINE__, __STDC__, __TIME__, __TIMESTAMP__ are "ANSI-Compliant Predefined Macros"

is that enough?

if you don''t want to "try for every statement" just put a big try around your initiation or something
try
{
engine.startup();
}
catch(exception& e)
{ // bla
}

and make sure your exceptions throw the info needed. You can also derive your own exception class to. Check the classes in the "stdexcept" header.

I also found this on bjarne''s homepage:
http://www.research.att.com/~bs/eh_brief.pdf

haven''t read it yet *too tired* but it might give some ideas?

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]

Share this post


Link to post
Share on other sites
quote:
Original post by GrinningGator
Assuming C++, you can use the __FILE__ and __LINE__ preprocessor macros (I think they are standard, though I have only used them in MSVC 6). They expand to standard C-style strings (null-terminated arrays of characters) with the file name and line number.

[edited by - GrinningGator on August 18, 2003 7:40:36 PM]



Yes thank you. I found those macros in the dbgheap.c file yesterday.

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!