Improved closure error handling