Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion internal/utils/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,22 @@ func ConnectByUrl(ctx context.Context, url string, options ...func(*pgx.ConnConf
}
cc.Fallbacks = fallbacks
})
return pgxv5.Connect(ctx, url, options...)
conn, err := pgxv5.Connect(ctx, url, options...)
var pgErr *pgconn.PgError
if errors.As(err, &pgErr) {
if strings.Contains(pgErr.Message, "connect: connection refused") {
CmdSuggestion = fmt.Sprintf("Make sure your local IP is allowed in Network Restrictions and Network Bans.\n%s/project/_/database/settings", CurrentProfile.DashboardURL)
} else if strings.Contains(pgErr.Message, "SSL connection is required") && viper.GetBool("DEBUG") {
CmdSuggestion = "SSL connection is not supported with --debug flag"
} else if strings.Contains(pgErr.Message, "SCRAM exchange: Wrong password") || strings.Contains(pgErr.Message, "failed SASL auth") {
// password authentication failed for user / invalid SCRAM server-final-message received from server
CmdSuggestion = "Try setting the SUPABASE_DB_PASSWORD environment variable"
} else if strings.Contains(pgErr.Message, "connect: no route to host") || strings.Contains(pgErr.Message, "Tenant or user not found") {
// Assumes IPv6 check has been performed before this
CmdSuggestion = "Make sure your project exists on profile: " + CurrentProfile.Name
}
}
return conn, err
}

const (
Expand Down
Loading