In many places we have "shouldn't-happen" situations where a functon
might return NULL or false.
Coming from working on Google code you might be tempted to use
CHECK(foobar != NULL).
But in client software, things that should never happen end up
happening all the time because of someone's strange computer setup or
cosmic rays. Our pattern is:
1) If it is just "this is highly unlikely", attempt to recover from the problem.
2) If it is "this shouldn't happen, and if it does a developer should
learn about it", use something like
if (!keyboard_has_spacebar) {
NOTREACHED() << " this keyboard is crazy, maybe our detection code
is wrong?";
return false; // attempt recovery anyway
}
3) If it really is something that's so bad that it's a security
problem if we continue, you should use CHECK(). But these should be
very rare.
--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected]
View archives, change email options, or unsubscribe:
http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---