fix pgx connection error for old version

This commit is contained in:
Livio Spring 2024-04-23 10:35:25 +02:00
parent f5da134b83
commit d5c30b120e
No known key found for this signature in database
GPG Key ID: 26BB1C2FA5952CF0

View File

@ -2,8 +2,8 @@ package gerrors
import (
"errors"
"strings"
"github.com/jackc/pgx/v5/pgconn"
"github.com/zitadel/logging"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@ -36,8 +36,7 @@ func ExtractZITADELError(err error) (c codes.Code, msg, id string, ok bool) {
if err == nil {
return codes.OK, "", "", false
}
connErr := new(pgconn.ConnectError)
if ok := errors.As(err, &connErr); ok {
if strings.Contains(err.Error(), "failed to connect to") { // version of pgx does not yet export the error type
return codes.Internal, "db connection error", "", true
}
zitadelErr := new(zerrors.ZitadelError)