handle errors from server