69. Establish a rational error handling policy, and follow it strictly

Summary

Consciously specify, and conscientiously apply, what so many projects leave to adhoc (mis)judgment: Develop a practical, consistent, and rational error handling policy early in design, and then stick to it. Ensure that it includes:

Identification: What conditions are errors.

Severity: How important or urgent each error is.

Detection: Which code is responsible for detecting the error.

Propagation: What mechanisms are used to report and propagate error notifications in each module.

Handling: What code is responsible for doing something about the error.

Reporting: How the error will be logged or users notified.

Change error handling mechanisms only on module ...

Get C++ Coding Standards: 101 Rules, Guidelines, and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.