![]() |
exception handling class
Hey,
I was wondering how to write a nice exception handling class... ive written one along the lines of: :
//this file - XHandler.hand I use it like: :
//this file - myclass.hin a source file i.e. :
//this file - main.cppthe obvious problem is it doesnt print the actual file and line where the exception was thrown - instead it returns the file it was declared in along with the line number - in that case the myclass.h file... how can i get it to print the file and line number where the exception actually occured - i.e. inside the file that contains the main function (main.cpp)... hope you can help! :D |
The only way myclass::dosomething() can throw an exception specifying the line in main() where it is called is for the information to be passed from main(). The obvious way would be to pass them as arguments.
:
class myclassIncidentally, your declaration of the GetException() member function and your usage of it don't match. |
Hey Grumpy!
Thanks for the reply! Yeah sorry I typed that out quickly... Well I guesss thats the solution... Bit messy tho! :/ Suppose we have a vector class and we want to divide by a scalar :
class vector {this might seem a little stupid - but would be nice to find out exactly where the error occured... or maybe its just plain stupid! |
Getting a stack trace is the domain of debuggers, not the programming language. And it's a capability you won't normally need in production code. So it's hardly surprising that you have to jump through hoops to get a comparable capability in code.
|
yeah good point!
|
sorry wrong post!
|
| All times are GMT -5. The time now is 2:03 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC