c++ - Throw (or correspondingly) on NULL function argument versus letting it all blow up? -


In the last large scale applications require high robustness and longer, I always for validating a pointer function argument when it was documented as "should ever be taped". I was throwing a std :: invalid_argument exception, or similarly, if the argument was actually zero in C ++ and error code in C.

However, I am doing a crash dump file that appears - what seems to be - it may be better just to have an application that can be blown instantly on the first NULL indicator variation in the same function. To start And a thorough testing process will find bad function calls

with a problem not will be found to be zero and letting the application blow, that indicator actually does not dereferenced in that function If it is stored for later use, then the reverse shock-out will be out of context and it will be very difficult to diagnose.

Any ideas or best practices on this?

Edit1: I forgot to mention that many of our codes are libraries for 3rd party developers, whether or not our internal error management policies Be aware but the functions are still properly documented!

This is an easy call when someone does not expect to get a zero pointer to a bug in the program There is a clear signal or a seriously compromised programmatic situation. Either the programmer needs to do something about it, by throwing an exception, it will work only when it is not caught. If it is caught, then the information about important diagnostics is greatly reduced, it throws all the important call stack which helps you to figure out how it came in that situation. If it is not caught, then there is no appreciable difference between the C ++ exception and the hardware exception.

The risk that the exception can be may be caught is to be caught somewhere that you don`t throw an exception and let it die.

This idea is very different for a runtime environment that can produce the call stack after the exception is caught. Normal in managed environment, not in original C / C ++


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -