Adds error logging.