FREE Udemy course: Error reporting in C++
09 February 2024
Reporting errors in a way that facilitates robust handling and debugging results in more correct and maintainable code. In this free Udemy course, I will teach you how to do that with C++, from the most basic to the most modern techniques.
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, learn principles, and best practices that are essential 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 are simple: When returning from a function that may fail, make correct code easy to write, and incorrect code hard to write.
We will be looking 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 kind of value, such as the contents of a file, and may fail.
The challenge is to find an ideal way to report an error if one occurs, while also returning the value if no error occurs.
Errors should be unignorable and unambiguous. If a function returns a value, we want to make sure 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, in the most expressive and simple way possible.
We will be looking at different ways to achieve this, from using exceptions, to returning empty or invalid values, error codes, and more. The lectures are code-centric, concise and are accompanied by interactive labs to help you practice what you have learned. In the coding exercises, you will be given some starter code with your task being to handle the output of a function that may fail. This will give you the opportunity to practice all the different error reporting techniques, while exploring their advantages and disadvantages.
Join me in this free Udemy course to learn how to report errors by writing code that’s hard to misuse and wrong code hard to get away with.