Add exception for bad type conversion

Fixes #8