Implemented error handling that previously crashed the REPL