throwing error when error returned from generation