Optimized error handling.