Optimized error handling