Add typed exceptions.

Closes #1