Error reporting in C++
Error reporting in C++, Facilitate robust and expressive error handling with your software design.
Course Description
Let’s explore how to report errors in C++ for software that’s both expressive and hard to misuse.
In this course, you will explore various error reporting mechanisms and essential best practices for creating robust and reliable software.
Error reporting is a crucial part of software development. It increases the correctness of software and makes it more maintainable. The goal of error reporting is simple: When returning from a function that may fail, make correct code easy to write and incorrect code hard to miss.
We will look at different ways to report errors in C++ and evaluate each technique based on its simplicity, expressiveness, and robustness. The techniques we will examine range from the most basic, essentially writing C, to the most modern, using C++23 features. The focus will be on functions that return some value, such as the contents of a file, and may fail.
The challenge is finding an ideal way to report an error if one occurs, while also returning the value if everything goes well.
Errors should be unignorable and unambiguous. If a function returns a value, we want to ensure that the caller cannot accidentally access that value if an error has occurred. Additionally, we would like the caller to know what went wrong in case of a mishap. All this, expressively and simply.
We will look at different ways to achieve this, from using exceptions to returning empty or invalid values, error codes, and more. The lectures are code-centric and concise. They are accompanied by interactive labs to help you practice what you have learned. In the coding exercises, you will get some starter code, and your task is to handle the output of a function that may fail. This will allow you to practice all the different error reporting techniques while exploring their advantages and disadvantages.
Join me in this course to learn how to report errors by writing code that’s hard to misuse and wrong code hard to get away with.