Custom error messages

Fixes #267