We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Failing Successfully: Reporting and Handling Errors - Robert Leahy - CppCon 2021
Learn how to design effective error-handling systems, emit informative error messages, and consider context, use case, and architecture implications for better software development.
- We should strive to emit more information-rich error messages, rather than just “magic” error codes.
- When designing error-handling systems, consider the context in which errors will be reported and handled.
- Deferring decisions about error handling to later stages in the call chain can be beneficial.
- Global variables and singleton patterns can be problematic and should be avoided.
- Error messages should not be assumed to be null or empty; consider providing default values or error-friendly ways to handle unexpected inputs. *idioms using error codes can be problematic and should be replaced with more explicit error-handling code.
- It’s important to consider the implications of error handling on the overall architecture and interfaces of a system.
- Naked exceptions should be avoided in favor of more explicit error handling.
- Clients using our code may have different expectations and requirements for error handling; we should strive to accommodate these differences.
- It’s crucial to maintain a high-level overview of the system, considering the context in which errors will be reported and handled.
- Error handling should be optimized for the needs and expectations of the specific use case.
- Ignoring or achieving errors is not the same as handling them successfully; we should strive to provide meaningful error messages and contextual information.
- Software engineers should prioritize designing code that is easy to understand, maintain, and extend, as well as handling errors in a way that is both effective and efficient.