handle error returned from server