Name: Anonymous 2012-07-04 20:46
//in some class or namespace:
typedef unsigned int error_code;
const error_code out_of_mem = 0x01,
niggers = 0x02,
jews = 0x04;
error_code f()
{
error_code ret = 0;
//do some stuff...
//suddenly niggers
ret |= niggers;
//but it's not a fatal error so we will continue execution
//...
if(some_pointer == nullptr)
{
ret |= out_of_mem;
goto cleanup;
}
//and so on...
cleanup:
delete some_pointer;
//etc...
return ret;
}
void implementation()
{
error_code f = f();
if( f & out_of_mem )
//handle error
printf("%s\n", "allocation failure");
if( f & niggers )
pool.close();
}The main point of exceptions is to separate error detection from error handling. This accomplishes that. If you need the advanced features of exceptions, take a good look at your design and, more importantly, your life.