Facilitate robust and expressive error handling with your software design

What you will learn

Understand the importance of error reporting in C++

Analyze the different error reporting techniques

Understand the risks of ambiguity when reporting errors

Evaluate the different error reporting techniques in regards to complexity

Write C++ that is easy to use correctly and hard to get wrong

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.


Get Instant Notification of New Courses on our Telegram channel.


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.

English
language

Content

Introduction

Introduction to the course
Introduction to the coding exercises
Sample lab

Error reporting in C++

Exceptions
Exceptions lab
Empty values
Empty values lab
Invalid values
Invalid values lab
Optional values
Optional values lab
Boolean values
Boolean values lab
Error codes
Error codes lab
Pairs of Booleans and content
Pairs of Booleans and content lab
Pairs of error codes and content
Pairs of error codes and content lab
Custom classes of Booleans and content
Custom classes of Booleans and content lab
Custom classes of error codes and content
Custom classes of error codes and content lab
Variants
Variant values lab
Expected
Expected values lab

Conclusion

Takeaways & reflections