refactoring error handling - part 1 (see top lexer.h)