13.2. Designing with Exceptions
The keyword try designates a try block, which is an area of your program that detects exceptions. Inside try blocks, we typically call functions that may raise or throw exceptions. The keyword catch designates a catch handler with a signature denoting an exception type. Catch handlers immediately follow try blocks or another catch handler with a different signature.
You must set up a try block and a catch handler to capture thrown exceptions. Otherwise, the exception is uncaught and your program terminates by default. Try blocks are important because their associated catch handlers determine what part of your program handles a specific exception. The code inside the catch handler is where you decide what to do ...
Get Navigating C++ and Object-Oriented Design 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.