I have an application with some bunch of code like this:
errCode = callMainSystem();
switch (errCode){
case FailErr: error("Err corresponding to val1\n");
case IgnoreErr: error("Err corresponding to val2\n");
...
...
default: error("Unknown error\n");
}
The values are enum constants. Will it make some sense to have something like:
// Error* callMainSystem()
... Some code
return FaileErr(); // or some other error
// handling code
Error* err = callMainSystem();
err->toString();
The Error class may be made singleton as it only has to print error messages.
What are the pros and cons of above methods,size is an important criteria as the application needs to be supported on embedded devices as well.
P.S: I don't want to use exception handling because of portability issues and associated overheads.