Author image

Exception Class Hierarchies in C++


How to use exceptions? How to manage error codes in your C++ programs? That is the question of the day.

Luckily c++ exceptions are pretty standard in their programming. The go-to strategy is to create a base exception class with a name of your choosing (KeyException was mine) and then you can create subclass exception classes, nested in the various principal classes of your codebase. As an example I've created the GameException class which you can use as a template to create other nested exception classes.

Let's start with a tiny C++ exception primer -reminder- though before you get your hands on the code.

1