bug in error throwing code (close #29, thanks to @lyro)