Added error handling code to port_agent_client.