Difference between revisions of "Cpp Coding Standards/ERR"
From Apache OpenOffice Wiki
m (Cpp Coding Standards/Error Handling moved to Cpp Coding Standards/ERR: consistency) |
(formatting) |
||
Line 1: | Line 1: | ||
− | + | === Error Handling (ERR) - Summary === | |
+ | ''How to distinguish and use exceptions, assertions and other error cases.'' | ||
− | + | ===== Assert Assumptions <span id="Assert">(Assert)</span> ===== | |
+ | Assert liberally to document internal assumptions and invariants. Don't use assertions for runtime errors.<br> | ||
+ | Ensure that assertions don't perform side effects.<br> | ||
+ | [[/Assert|-> Details]] | ||
− | + | ===== Function Safety Guarantees <span id="Safe">(Safe)</span> ===== | |
− | = | + | Provide the strongest error-safety guarantee for each function that does not punish callers who do not need it. The basic guarantee is always necessary. [[/Safe|-> Details]] |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | ==== Function Safety Guarantees <span id="Safe">(Safe)</span> ==== | + | |
− | Provide the strongest error-safety guarantee for each function that does not punish callers who do not need it. The basic guarantee is always necessary. | + | |
− | + | ||
− | [[/Safe| | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | [[/ | + | ===== Which Functions Never Fail <span id="NoFail">(NoFail)</span> ===== |
+ | Destructors, delete operators and swap functions must never fail. Occurring exceptions have to be catched and handled within the same function. [[/NoFail|-> Details]] | ||
− | ==== | + | ===== Throwing and Catching Exceptions <span id="HowThrow">(HowThrow)</span> ===== |
− | + | Throw exceptions by value, catch them by reference. [[/HowThrow|-> Details]] | |
− | [[/ExSpec|Details]] | + | ===== Avoid Exception Specifications <span id="ExSpec">(ExSpec)</span> ===== |
+ | Don't write exception specifications on your functions. [[/ExSpec|-> Details]] | ||
---- | ---- | ||
Related Rules | Related Rules | ||
− | * [[../ | + | * [[../PRINC#ErrHdl |PRINC:ErrHdl]] - Consistent Error Handling |
---- | ---- | ||
[[Category:Coding Standards]] | [[Category:Coding Standards]] |
Revision as of 16:04, 22 May 2007
Contents
Error Handling (ERR) - Summary
How to distinguish and use exceptions, assertions and other error cases.
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.
-> Details
Function Safety Guarantees (Safe)
Provide the strongest error-safety guarantee for each function that does not punish callers who do not need it. The basic guarantee is always necessary. -> Details
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. -> Details
Throwing and Catching Exceptions (HowThrow)
Throw exceptions by value, catch them by reference. -> Details
Avoid Exception Specifications (ExSpec)
Don't write exception specifications on your functions. -> Details
Related Rules
- PRINC:ErrHdl - Consistent Error Handling