classifyUserUniqueViolation (store/user_unique.go)

memos · store/user_unique.go · go · MIT
database, tag:embed-classified

Maps database unique‑constraint errors to typed user‑identity errors.

// Source: https://github.com/usememos/memos | License: MIT | Copyright 2025 Memos
// Provided via justclaw.it.com; keep this notice with the code.
package store

import (
	stderrors "errors"
	"strings"

	"github.com/pkg/errors"
)

// ErrEmailTaken reports that another user already holds the email address.
var ErrEmailTaken = stderrors.New("email is already in use")

// ErrUsernameTaken reports that another user already holds the username.
var ErrUsernameTaken = stderrors.New("username is already in use")

// ErrUserIdentityTaken reports that an external identity linkage already
// exists, either for the same (provider, extern_uid) pair or for the same
// (user, provider) pair.
var ErrUserIdentityTaken = stderrors.New("user identity is already linked")

// uniqueViolationMarkers precede th

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key