From c16dd3d580e773196835dd83b7bc0eb7890a2768 Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Thu, 22 Feb 2024 08:22:26 -0700 Subject: [PATCH] feat: improve PG database initialization errors --- backends/postgres/postgres_backend.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backends/postgres/postgres_backend.go b/backends/postgres/postgres_backend.go index c077823..9e4e8d9 100644 --- a/backends/postgres/postgres_backend.go +++ b/backends/postgres/postgres_backend.go @@ -146,7 +146,7 @@ func Backend(ctx context.Context, opts ...neoq.ConfigOption) (pb neoq.Neoq, err err = p.initializeDB() if err != nil { - return + return nil, fmt.Errorf("unable to initialize jobs database: %w", err) } if p.pool == nil { //nolint: nestif @@ -175,13 +175,14 @@ func Backend(ctx context.Context, opts ...neoq.ConfigOption) (pb neoq.Neoq, err p.pool, err = pgxpool.NewWithConfig(ctx, poolConfig) if err != nil { - return + return nil, fmt.Errorf("unable to create worker connection pool: %w", err) } } p.listenerConn, err = p.newListenerConn(ctx) if err != nil { p.logger.Error("unable to initialize listener connection", slog.Any("error", err)) + return nil, fmt.Errorf("unable to create neoq listener connection: %w", err) } // monitor handlers for changes and LISTEN when new queues are added