d2d1: Add a helper to set error state.