fix pgx connection error for old version

(cherry picked from commit d5c30b120e)
This commit is contained in:
Livio Spring 2024-04-23 10:35:25 +02:00
parent 13ddf707ab
commit 98349c8eaf
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)