Error handling...
In Unreal when an error occurs a dialog is shown containing the function call where the error occurred on, something like this: "pProgram->Initialize()".
I´ll explain what I´m doing right now.
...
bFailed = pProgram->Initialize();
if ( bFailed )
{
pErrorHandler->ReportError( __FILE__, __LINE__, "pProgram->Intialize()" );
}
...
This works, but I find it inefficient to type out the whole function every time. Can you guys come up with a more efficient way to this?
----------
Mail me, Drago''s OpenGL Website
osu!
What i do is define a macro such as:
#define ReportError2(lpOutputString) ReportError(__FILE__,__LINE__,lpOutputString)
if you include this in the declaration of your errorhandler class you can call it using:
...
bFailed = pProgram->Initialize();
if ( bFailed )
{
pErrorHandler->ReportError2("pProgram->Intialize()" );
}
...
===========================
No sense being pessimistic. It wouldn''''t work anyway.
#define ReportError2(lpOutputString) ReportError(__FILE__,__LINE__,lpOutputString)
if you include this in the declaration of your errorhandler class you can call it using:
...
bFailed = pProgram->Initialize();
if ( bFailed )
{
pErrorHandler->ReportError2("pProgram->Intialize()" );
}
...
===========================
No sense being pessimistic. It wouldn''''t work anyway.
===========================There are 10 types of people in the world. Those that understand binary and those that don't.( My views in no way reflect the views of my employer. )
You can make some macros using the stringizing operator:-
...Umm... I Think...
Then just type:-
REPORT_ERROR(pErrorHandler, "pProgram->Intialize()")
Pity, there''s no standard __FUNCTION__ like macro, then you could automate all of it...
As for Unreal, I think it pushes text into a buffer by throwing exceptions, because there''s a lot of ''x->y->z->u()'' text to write manually otherwise.
Jans.
#define LINE_STR1(n) #n#define LINE_STR2(n) LINE_STR1(n)#define LINE_STRING LINE_STR2(__LINE__) #define FILE_STRING __FILE__#define REPORT_ERROR(pObj, szText) pObj->ReportError(FILE_STRING, LINE_STRING, szText)
...Umm... I Think...
Then just type:-
REPORT_ERROR(pErrorHandler, "pProgram->Intialize()")
Pity, there''s no standard __FUNCTION__ like macro, then you could automate all of it...
As for Unreal, I think it pushes text into a buffer by throwing exceptions, because there''s a lot of ''x->y->z->u()'' text to write manually otherwise.
Jans.
I actually do a form of that as well, but didn´t show it to keep the question simple.
This is what I really do:
#define M_FAILED(x) ( x < 1 )
#define M_FAIL_SAFE(f, fn, em) if ( M_FAILED( f ) ) g_pErrorHandler->ProcessError( __FILE__, __LINE__, fn, em );
M_FAIL_SAFE
(
InitializeProgram(),
"InitializeProgram()",
"Failed to initialize the program..."
);
But I doubt if this is good coding practise, but it does safe me from more mindless typing .
----------
Mail me, Drago's OpenGL Website
Edited by - drago on January 12, 2001 5:06:43 PM
This is what I really do:
#define M_FAILED(x) ( x < 1 )
#define M_FAIL_SAFE(f, fn, em) if ( M_FAILED( f ) ) g_pErrorHandler->ProcessError( __FILE__, __LINE__, fn, em );
M_FAIL_SAFE
(
InitializeProgram(),
"InitializeProgram()",
"Failed to initialize the program..."
);
But I doubt if this is good coding practise, but it does safe me from more mindless typing .
----------
Mail me, Drago's OpenGL Website
Edited by - drago on January 12, 2001 5:06:43 PM
osu!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement