Check and handle server error messages

Change-Id: I36b9ec321687e64019bf7ef7e34d8b9cbdb47f6f