Improved error handling in client