Fix throwing errors into the generator

Fixes issue #5
Merge pull request #6 from TomiBelan/fix5

Fix throwing errors into the generator