Replaced the exit with a throw error