Corrected error handling in generate scripts.