Exception Handling

Handle errors gracefully with try, catch, and throw. Use exceptions for error recovery.

54 lessons
209 min

Lessons

1. Intro

Error handling with exceptions

4m

2. What Are Exceptions?

Separating errors from logic

4m

3. Why Exceptions?

Error codes get ignored

4m

4. The try Block

Marking risky operations

4m

5. The throw Statement

Triggering exception handling

4m

6. Quiz: Exception handling

Exception handling

3m1 problems

7. The catch Block

Responding to exceptions

4m

8. Basic try-catch Example

First exception handler

6m

9. Quiz: Exception handling

Exception handling

3m1 problems

10. Quiz: try-catch Basics

Knowledge check

3m1 problems

11. Catching by Value vs Reference

Avoiding object slicing

4m

12. Multiple catch Blocks

Handling different error types

4m

13. Quiz: Variable alias

Variable alias

3m1 problems

14. Catch-All Handler (catch(...))

Unknown exception types

4m

15. Standard Exception Classes

Built-in error types

4m

16. Quiz: Error signaling

Error signaling

3m1 problems

17. std::exception Base Class

Top of exception hierarchy

4m

18. std::runtime_error and std::logic_error

Two main exception categories

4m

19. Quiz: Error signaling

Error signaling

3m1 problems

20. Quiz: Exception Categories

Knowledge check

3m1 problems

21. std::out_of_range, std::invalid_argument

Specific error types

4m

22. Creating Custom Exceptions

Domain-specific error types

4m

23. Quiz: Error signaling

Error signaling

3m1 problems

24. Inheriting from std::exception

Proper exception derivation

4m

25. The what Method

Getting error descriptions

4m

26. Quiz: Error signaling

Error signaling

3m1 problems

27. Rethrowing Exceptions

Passing errors upward

4m

28. Exception Propagation

How exceptions travel upward

4m

29. Quiz: Error signaling

Error signaling

3m1 problems

30. Quiz: Stack Unwinding

Knowledge check

3m1 problems

31. noexcept Specifier

Functions that never throw

4m

32. When to Use Exceptions

Choosing error mechanisms

4m

33. Quiz: Error signaling

Error signaling

3m1 problems

34. Exceptions vs Error Codes

Comparing error strategies

4m

35. Quiz: When to Use Exceptions

Knowledge check

3m1 problems

36. Exception Safety Basics

Guarantees about error states

4m

37. RAII and Exceptions

Automatic resource cleanup

4m

38. Quiz: Error signaling

Error signaling

3m1 problems

39. Quiz: Exception Safety

Knowledge check

3m1 problems

40. Practice Problems

Apply exception handling

4m1 problems

41. Section 18 Recap

Exception handling review

5m

42. Problem - Safe Division

Error handling fundamentals

4m1 problems

43. Safe Division - The Idea

Exception benefits

5m

44. Safe Division - Algorithm

Implementation approach

4m

45. Quiz: Integer division

Integer division

3m1 problems

46. Safe Division - Implementation

Pseudocode solution

6m1 problems

47. Lessons from Safe Division

summary

4m

48. Problem - Input Validator

Catching different errors

4m1 problems

49. Input Validator - The Idea

Catching by type

5m

50. Input Validator - Algorithm

Implementation approach

4m

51. Quiz: Error signaling

Error signaling

3m1 problems

52. Input Validator - Implementation

Pseudocode solution

6m1 problems

53. Lessons from Input Validator

summary

4m

54. Section Recap

What we learned

5m

Ready to start learning?

Access all 54 lessons with interactive content and progress tracking.