Is there a term for the error-handling anti-pattern of discarding all available info and just returning failure?
https://softwareengineering.stackexchange.com/questions/105905
-
02-11-2019 - |
Question
From time to time (unfortunately way too often) I have to fix code such as this:
// C++ code
bool anyOldFunction(Param p) {
try {
...
if(some_condition_here) {
handleErrorX();
return false;
} else if(other_condition) {
return false; // (*stackexchange question comment*) Apparently no additional error action taken here
}
...
return true;
} catch(...) {
// (*old comment*) Catch all possible error (FroobleFub and BrabbleBub can happen)
return false;
}
}
So, the original implementer actually had some inkling what exceptions could be thrown (although the list may not be exhaustive) but had no idea how to do some decent handling and just discarded any info he might have gotten out of the exception objects, leaving the calling code / the calling context non-the-wiser.
Is there a name for this anti-pattern? (If anti-pattern it is indeed.)
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with softwareengineering.stackexchange