Add a common exception base class

Fixes #9
Fixes #21