Clean up error handling code in client