test writeError()