Allow the main loop to return an error to the caller