lexer: Improve error handling.