package httpgateway

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

const ServiceID = 11

//nolint:mnd // ignore magic number here
var (
	ErrCodeParseRowFail    = bizerr.NewInternalErrCode(ServiceID, 1, "ErrCodeParseRowFail")
	ErrCodeParseResultFail = bizerr.NewInternalErrCode(ServiceID, 2, "ErrCodeParseResultFail")
	ErrCodeCommitFail      = bizerr.NewInternalErrCode(ServiceID, 3, "ErrCodeCommitFail")
	ErrCodeRollBackFail    = bizerr.NewInternalErrCode(ServiceID, 4, "ErrCodeRollBackFail")

	ErrCodeOpenDBFail           = bizerr.NewBusinessErrCode(ServiceID, 1, "ErrCodeOpenDBFail")
	ErrCodeQueryFail            = bizerr.NewBusinessErrCode(ServiceID, 2, "ErrCodeQueryFail")
	ErrCodeBeginTxnFail         = bizerr.NewBusinessErrCode(ServiceID, 3, "ErrCodeBeginTxnFail")
	ErrCodeEmptyTx              = bizerr.NewBusinessErrCode(ServiceID, 4, "ErrCodeEmptyTx")
	ErrCodeSessionExpired       = bizerr.NewBusinessErrCode(ServiceID, 5, "ErrCodeSessionExpired")
	ErrCodeUnsupportedIsolation = bizerr.NewBusinessErrCode(ServiceID, 6, "ErrCodeUnsupportedIsolation")
)

const (
	UnknownInternalErrorMessage = "Unknown Internal Server Error"
	InvalidSessionErrorMessage  = "Invalid session, please provide the correct session and retry"
	EmptyAuthErrorMessage       = "Empty Authorization header"
	InvalidAuthErrorMessage     = "Invalid Basic Auth value"
	InvalidBodyErrorMessage     = "Invalid body, please provide the correct body and retry"
	UnsupportedSQLMessage       = "Unsupported SQL. Support DQL, DML and DDL now"
	BeginWithSessionMessage     = "Session can not be set when begin a transaction"
	TxnWithoutSessionMessage    = "Session must be set when execute transaction"

	ErrCodeParseRowFailMessage    = "Failed to parse row"
	ErrCodeParseResultFailMessage = "Failed to parse result"
	ErrCodeQueryFailMessage       = "Execute SQL fail"
	ParseSQLFailMessage           = "You have an error in your SQL syntax"
	ErrCodeOpenDBFailMessage      = "Failed to open DB connection"

	ErrCodeBeginFailMessage    = "Begin transaction fail"
	ErrCodeCommitFailMessage   = "Commit transaction fail"
	ErrCodeRollBackFailMessage = "Rollback transaction fail"
	//nolint:lll // ignore long line here
	TxExpiredErrorMessage     = "Transaction connection expired, please restart a new transaction and retry"
	TxNotFoundErrorMessage    = "Transaction connection not found, invalid session or the transaction has been closed/cleaned"
	TxConcurrencyErrorMessage = "Transaction can not be used concurrently, please retry the request after the previous one is finished"
	// stateful non transaction session error messages
	StatefulExpiredErrorMessage     = "Stateful connection expired, please restart a new connection and retry"
	StatefulConcurrencyErrorMessage = "Stateful connection can not be used concurrently, please retry the request after the previous one is finished"
	StatefulNotFoundErrorMessage    = "Stateful connection not found, invalid session or the connection has been closed/cleaned"

	UnsupportedIsolationMessage = "Unsupported transaction isolation level"
)
