Fix error handling in repl