Error handling for model generation