Avoid infinite looping if server returns error message