You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: subtask_phase.go
    path of file: ./repos/flyte/flyteplugins/go/tasks/plugins/array
    
    the code of the file until where you have to start completion: package array

import (
	"context"

	"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
	"github.com/flyteorg/flyte/flytestdlib/errors"
	"github.com/flyteorg/flyte/flytestdlib/logger"
	"github.com/flyteorg/flyte/flytestdlib/storage"
)

const (
	ErrSystem errors.ErrorCode = "SYSTEM_ERROR"
)

func CheckTaskOutput(ctx context.Context, dataStore *storage.DataStore, outputPrefix, baseOutputSandbox storage.DataReference, childIdx, originalIdx int) (core.Phase, error) {
	or, err := ConstructOutputReader(ctx, dataStore, outputPrefix, baseOutputSandbox, originalIdx)
	if err != nil {
		return core.PhaseUndefined, errors.Wrapf(ErrSystem, err, "Failed to build output reader for sub task [%v] with original index [%v].", childIdx, originalIdx)
	}

	outputExists, err := or.Exists(ctx)
	if err != nil {
		return core.PhaseUndefined, errors.Wrapf(ErrSystem, err, "Failed to check if output file exists for sub task [%v] with original index [%v].", childIdx, originalIdx)
	}

	if !outputExists {
		errExists, err := or.IsError(ctx)
	
    
func CheckTaskOutput(ctx context.Context, dataStore *storage.DataStore, outputPrefix, baseOutputSandbox storage.DataReference, childIdx, originalIdx int) (core.Phase, error) {
	or, err := ConstructOutputReader(ctx, dataStore, outputPrefix, baseOutputSandbox, originalIdx)
	if err != nil {
		return core.PhaseUndefined, errors.Wrapf(ErrSystem, err, "Failed to build output reader for sub task [%v] with original index [%v].", childIdx, originalIdx)
	}

	outputExists, err := or.Exists(ctx)
	if err != nil {
		return core.PhaseUndefined, errors.Wrapf(ErrSystem, err, "Failed to check if output file exists for sub task [%v] with original index [%v].", childIdx, originalIdx)
	}

	if !outputExists {
		errExists, err := or.IsError(ctx)
		if err != nil {
			return core.PhaseUndefined, errors.Wrapf(ErrSystem, err, "Failed to check if error file exists for sub task [%v] with original index [%v].", childIdx, originalIdx)
		}

		if errExists {
			logger.Debugf(ctx, "Found error file for sub task [%v] with original index [%v]. Marking as failure.",
				childIdx, originalIdx)
			return core.PhaseRetryableFailure, nil
		}
	}

	return core.PhaseSuccess, nil
}