Fix infinite loop bug in error module. Closes #150.