fix handling of early errors

Fixes #393.