Improving error handling for client.