package errorcode

import (
	"context"

	"github.com/tidbcloud/pkgv2/bizerr"
)

var BranchErrorMessages = map[bizerr.ErrCode]string{
	ErrCodeBranchNameReserved:                   "The branch name you're trying to use is reserved by TiDB Cloud for future purposes. Please select an alternative name for your branch.",
	ErrCodeClusterNotRunning:                    "Cluster is currently not available. Please wait for it to become available before attempting to create branches again.",
	ErrCodeCreateBranchFromThrottledCluster:     "Creating branches is not allowed for clusters that reach the Spending Limit and are experiencing throttling.",
	ErrCodeBranchNotRunning:                     "Branch is not running, can not perform actions on it.",
	ErrCodeBranchNotBelongToMainBranch:          "Branch does not belong to the cluster. Please check your cluster id.",
	ErrCodeBranchNameInvalidLength:              "The branch name should not be empty or longer than 64 characters. Please select an alternative name for your branch.",
	bizerr.ErrCodeRecordExist:                   "The branch name you're trying to use is already used. Please select an alternative name for your branch.",
	bizerr.ErrCodeRecordNotFound:                "The branch can not be found. Please check your branch id.",
	ErrCodeCreateBranchNotFromServerlessCluster: "Branch is not supported for TiDB Dedicated clusters.",
	ErrCodeInvalidBranchAnnotation:              "The branch annotation is invalid. Please check your annotation.",
	ErrCodeDeleteBranchHasChildren:              "Cannot delete branch that has children.",
	ErrCodeBranchParentOrChildNotRunning:        "Branch parent or child is not running, can not perform actions on it.",
}

func PrepareBranchErrorMessage(ctx context.Context, err error) bizerr.BizError {
	return PrepareErrorMessage(ctx, err, BranchErrorMessages)
}
