
Learn to throw and catch exceptions in C++, using try blocks, catch clauses, and by value or by reference handling; explore int, user-defined types, and pointers.
the video explains c++ exception handling, showing how concrete and base exceptions are matched by catch-block order, why concrete must come first, and that catch-all is placed at the end.
Learn the three restrictions on C++ exception handling: cannot throw or catch incomplete types; cannot catch an abstract type by value; catch-by-reference works for complete types.
Explore how exceptions and multiple inheritance interact in C++ by building custom exception types that inherit from std::exception, showing how virtual inheritance removes ambiguity so a combined exception is catchable.
Understand how exception objects are created, copied, and destroyed, with copy and move constructors and temporary objects. Learn why catching by reference prevents slicing and minimizes copies.
Understand how stack unwinding starts when an exception is thrown, how automatic objects are destroyed in reverse construction order, and how try and catch blocks guide program control flow.
Explore when to throw from constructors to signal object creation, delegated constructors, how stack unwinding affects object lifetime and destructor calls, and why throwing from destructors leads to termination.
Explore real-world C++ exceptions by inspecting open source projects and examining how exceptions are thrown and caught, including io base failure, runtime errors, and user defined exceptions.
Explore throwing and catching exceptions in C++, using try and catch, and rethrowing to outer handlers. Understand nested try and catch blocks, stack unwinding, and the fate of unmatched exceptions.
Capture the current exception with an exception pointer, preserve its lifetime, and pass it to other functions or threads. Check for empty pointers before rethrowing.
Explore nested try-catch blocks that nest a runtime_error inside an outer logic_error, using a polymorphic mixin to propagate and handle exceptions recursively.
Create your own exception types by deriving from std::exception (or runtime_error/logic_error), override what(), and use constructors or inherited constructors. Catch them polymorphically and read messages with what().
Learn standard exceptions in C++. Distinguish runtime_error from logic_error and see how they derive from the exception base to handle post-execution versus pre-execution errors.
Explore dynamic exception specification in C++ by detailing which exception types a function may throw, including runtimeError and logicError, and learn outcomes when an unexpected or unlisted type is thrown.
Explore how violating a dynamic exception specification in C++ triggers the unexpected handler, may terminate the program, or allow stack unwinding and catching via expected or runtime_error.
Explains the noexcept specifier in C++, distinguishes non throwing from potentially throwing functions, and notes termination without stack unwinding when a non throwing function throws.
Compare dynamic exception specification and noexcept in C++, showing how dynamic specifications trigger unexpected and stack unwinding, while noexcept terminates immediately without unwinding, with explicit examples and C++17 removal notes.
Explains that the noexcept specifier can be applied to free functions, member functions, lambdas, and function pointers, while noting overload restrictions and its status as a function-type trait since C++17.
Identify potentially throwing versus non throwing functions, focusing on destructors, noexcept specifications, and defaulted versus user defined constructors.
Explain why non throwing destructors are important in C++ exception handling, showing that destructors shouldn't throw, because throwing during stack unwinding causes termination.
Explain noexcept in interfaces with a base abstract class and derived overrides, showing that non throwing bases require non throwing overrides, while potentially throwing bases permit either.
Learn when to use the noexcept specifier in C++ by comparing potentially throwing versus non throwing functions, noting limited performance gains and guidelines for constructors, moves, and base interfaces.
Explore how the noexcept operator performs a compile-time check to determine if an expression is potentially throwing, without runtime evaluation, and see examples with expressions and function calls.
Understand how the noexcept operator performs a compile-time check to see if an expression may throw, without inspecting function bodies, and how it differs from the noexcept specifier.
Demonstrate using the noexcept operator with template functions to make expressions non-throwing, by overloading to_string for point and player and a print all function.
Demonstrate using the noexcept operator with templates to build a factory from argument packs and verify at compile time whether constructions are noexcept, as shown by string vs point cases.
Learn to use the noexcept operator to check whether special functions and methods are noexcept, including default, copy, and other constructors, and how std::declval helps probe expressions without objects.
Explore how the noexcept operator guides move versus copy decisions for a type with a large vector, using noexcept checks on special functions to optimize performance.
Understand how the noexcept operator evaluates an expression's potential exceptions. It returns true when that set is empty, and false otherwise, including function calls and dynamic_cast cases.
Explore C++ exception safety guarantees, including no throw, strong, basic, and no exception guarantee, with commit roll back semantics and preserved state under exceptions.
Explore no exception guarantee in C++ by demonstrating resource leaks, improper sequencing with unique pointers, and the importance of RAII, separating modifying and non-modifying operations to preserve invariants.
Explain the basic exception guarantee in C++, even when an exception occurs, objects stay in a valid state, invariants hold, and no resources leak.
Learn how strong exception guarantees preserve invariant and prevent side effects by rolling back to prior state, with a two-phase approach: collect data, then write to file in one operation.
Explain the no throw exception guarantee in C++, ensuring functions do not let exceptions escape while handling internal failures and guiding resource management toward strong exception safety.
While writing and running software, sooner or later exceptions or some other form of errors are unavoidable, whether expected or not, resulting from issues in our code or user actions, etc. Hence, we must be prepared for exceptions / errors and know how to handle them properly (whether gracefully or failing fast) to recover from or at least not exacerbate problems in our programs, including those written in languages like C++.
So, if you’ve just learned the basics of C++ and haven’t dived into exceptions yet or worked with C++ for a while but need to brush up on exceptions, then this course is for you. It’s about exceptions handling in C++, including theory, syntax and best practices. The course covers C++ standards 11-17.
By the end of this course you will learn
Throwing and catching exceptions and their limitations;
Stack unwinding;
Pitfalls when throwing in constructors and destructors;
Re-throwing and nested exceptions;
User-defined and standard exceptions;
Dynamic exceptions specification;
Noexcept specifier and noexcept operator;
Recommendations on error handling from C++ Core Guidelines.
Moreover, and probably most importantly, you will learn how to reason about exception safety of your code and exception safety guarantees, a concept that will help you write robust code in C++ and other similar languages.
So what exactly is covered in the course?
Lectures with code examples and explanations;
Summaries in PDF files from each lecture for those who prefer reading and to be able to quickly to back to specific topics and recap;
References to relevant C++ Core Guidelines about error handling;
Quizzes with questions to check your knowledge.
What is expected from you?
Please note that this course is not for complete beginners. At least basic C++ skills are required. And you should be able to read and understand C++ code examples of low to medium complexity and size that we cover in lectures.
So, does that sound like this course is for you? If yes, without further to do, enroll and I will see you in the course.
The images in visual examples are from website pixabay and the audio in videos is from website bensound.