Difference between revisions of "Cpp Coding Standards/ERR"
From Apache OpenOffice Wiki
m (→Avoid Exception Specifications <span id="ExSpec">(ExSpec)</span>) |
|||
Line 28: | Line 28: | ||
==== Avoid Exception Specifications <span id="ExSpec">(ExSpec)</span> ==== | ==== Avoid Exception Specifications <span id="ExSpec">(ExSpec)</span> ==== | ||
Don't write exception specifications on your functions. | Don't write exception specifications on your functions. | ||
− | |||
− | |||
[[/ExSpec|Details]] | [[/ExSpec|Details]] |
Revision as of 12:46, 2 February 2007
Topic-Id: ERR
How to distinguish and use exceptions, assertions and other error cases.
Contents
Summary
Assert Assumptions (Assert)
Assert liberally to document internal assumptions and invariants. Don't use assertions for runtime errors. Ensure that assertions don't perform side effects.
Function Safety Guarantees (Safe)
For each function, give the strongest error-safety guarantee that won't penalize callers who don't need it. Always give at least the basic guarantee.
Which Functions Never Fail (NoFail)
Destructors, delete operators and swap functions must never fail. Occurring exceptions have to be catched and handled within the same function.
Throwing and Catching Exceptions (HowThrow)
Throw exceptions by value, catch them by reference.
Avoid Exception Specifications (ExSpec)
Don't write exception specifications on your functions.
Related Rules
- PRINC:ErrHdl - Consistent Error Handling