5
Handling Errors with C++
This chapter will focus on error handling in C++. As a programmer, you will inevitably encounter situations where you need to determine the best approach to propagate program errors. Whether you use error codes or exceptions, we will delve into them to gain a better understanding of how to use them effectively.
In this chapter, we will examine how to handle errors reported by POSIX APIs using C++. We will begin by covering the errno thread-local variable and the strerror function. After that, we will introduce std::error_code and std::error_condition and demonstrate how they help to wrap POSIX errors that come from POSIX APIs. We will also investigate custom error categories, which allow us to compare errors produced ...
Get C++ Programming for Linux Systems 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.