raise Error when buf closed.