Refactored client error handling