Add error message when generator is invalid

Fixes #276, #277