package verification

import (
	"errors"
	"fmt"
)

var (
	ErrTokenNotFound         = errors.New("vtNotFound")
	ErrTokenAlreadyUsed      = errors.New("vtAlreadyUsed")
	ErrTokenExpired          = errors.New("vtExpired")
	ErrTokenAttemptsExceeded = errors.New("vtAttemptsExceeded")
	ErrCooldownActive        = errors.New("vtCooldownActive")
	ErrIdempotencyConflict   = errors.New("vtIdempotencyConflict")
)

func wrap(err error, msg string) error {
	return fmt.Errorf("%w: %s", err, msg)
}

func ErorrTokenNotFound() error {
	return wrap(ErrTokenNotFound, "verification token not found")
}

func ErorrTokenAlreadyUsed() error {
	return wrap(ErrTokenAlreadyUsed, "verification token has already been used")
}

func ErorrTokenExpired() error {
	return wrap(ErrTokenExpired, "verification token expired")
}

func ErrorCooldownActive() error {
	return wrap(ErrCooldownActive, "token creation cooldown is active")
}

func ErrorTokenAttemptsExceeded() error {
	return wrap(ErrTokenAttemptsExceeded, "verification token max attempts exceeded")
}

func ErrorIdempotencyConflict() error {
	return wrap(ErrIdempotencyConflict, "verification token request idempotency key has already been used")
}
