Exceptions

Functions should validate that their arguments are correct and throw otherwise.

Functions should also validate that their preconditions are met (unless documented otherwise.) If the function's preconditions are not met, throw

Document thrown exceptions in the documenting comment.

Never ignore errors in a try...catch. If the error must be ignored, print a warning to console, or at least comment why it is ignored.

"Unreachable" catch statements must still rethrow their errors just in case

When using C++, make sure to catch exceptions by const &

Last updated

Was this helpful?