Billionmail/BillionMail · error

failed to get all domains: %w

Error message

failed to get all domains: %w

What it means

GetDomainAll wraps an error from domains.All(ctx) into a gerror with gcode.CodeInternalError and sets it on the response via SetError. It signals the database-backed query that enumerates all domains failed; the SQL/database error text is embedded in the message.

Source

Thrown at core/internal/controller/domains/domains_v1_get_domain_all.go:21

import (
	"billionmail-core/internal/service/domains"
	"billionmail-core/internal/service/public"
	"context"
	"fmt"

	"github.com/gogf/gf/v2/errors/gcode"
	"github.com/gogf/gf/v2/errors/gerror"

	"billionmail-core/api/domains/v1"
)

func (c *ControllerV1) GetDomainAll(ctx context.Context, req *v1.GetDomainAllReq) (res *v1.GetDomainAllRes, err error) {
	res = &v1.GetDomainAllRes{}

	res.Data, err = domains.All(ctx)

	if err != nil {
		res.SetError(fmt.Errorf("failed to get all domains: %w", gerror.NewCode(gcode.CodeInternalError, err.Error())))
		return
	}

	res.SetSuccess(public.LangCtx(ctx, "Success"))
	return
}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Read the wrapped message for the underlying DB error (connection refused vs SQL syntax vs relation does not exist).
  2. Verify PostgreSQL is up and reachable: check docker compose ps and connection settings in the config.
  3. Run pending migrations so the 'domains' table exists.
  4. Test credentials with psql; if pool exhaustion, raise pool limits or check for leaked connections.
Defensive patterns

Strategy: retry

Validate before calling

// health-check DB before calling
if err := gdb.Config().Master.Ping(); err != nil {
	return fmt.Errorf("database unreachable: %w", err)
}

Try / catch

res, err := client.GetDomainAll(ctx, req)
if err != nil {
	var gerr *gerror.Error
	if errors.As(err, &gerr) && gerr.Code() == gcode.CodeInternalError {
		return backoff.Retry(func() error {
			_, err = client.GetDomainAll(ctx, req)
			return err
		}, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3))
	}
	return err
}

Prevention

When it happens

Trigger: domains.All(ctx) returns an error — typically a PostgreSQL failure: DB unreachable, connection pool exhausted, 'domains' table missing (migration not run), or a query timeout.

Common situations: Postgres container down or restarting during deploy; wrong DB credentials in config; schema migrations not applied after an upgrade; network partition between app and DB in Docker Compose.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/6b4a2398ec82704c. Report an issue: GitHub.