J
JackC
Hi,
If I have a long boolean function that has regular error checking
throughout, and simply returns false upon an error, whats the best
approach to getting detailed information about the error in the code
segment that called the function?
For example in a function:
{
....
open filea
check(filea open failed)
return false
open fileb
check(fileb open failed)
return false
....
}
How could i alter this so that the code that calls the above function
can tell if filea or fileb failed with a detailed error message for
the user?
My theoretical approach, which might be wrong is as follows:
I would create a public variable in my class : string LAST_ERROR;
then set this with detailed information right before 'return false',
then the calling segment could read the contents of last error, and
echo it to the user.
Is this the best approach to error handling? I have heard about using
error codes, but i cant think how i this could be implemented, or if
there is a more standardized method.
Thanks for any advice,
Jack
If I have a long boolean function that has regular error checking
throughout, and simply returns false upon an error, whats the best
approach to getting detailed information about the error in the code
segment that called the function?
For example in a function:
{
....
open filea
check(filea open failed)
return false
open fileb
check(fileb open failed)
return false
....
}
How could i alter this so that the code that calls the above function
can tell if filea or fileb failed with a detailed error message for
the user?
My theoretical approach, which might be wrong is as follows:
I would create a public variable in my class : string LAST_ERROR;
then set this with detailed information right before 'return false',
then the calling segment could read the contents of last error, and
echo it to the user.
Is this the best approach to error handling? I have heard about using
error codes, but i cant think how i this could be implemented, or if
there is a more standardized method.
Thanks for any advice,
Jack