From f6e1ab54d4edf5fb09dded016543b052e02592ab Mon Sep 17 00:00:00 2001 From: ice-myles <96409608+ice-myles@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:11:06 +0300 Subject: [PATCH] Handle only postgres and network errors as unexpected. --- connectors/storage/v2/api.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/connectors/storage/v2/api.go b/connectors/storage/v2/api.go index 83736a8..09bc343 100644 --- a/connectors/storage/v2/api.go +++ b/connectors/storage/v2/api.go @@ -4,6 +4,7 @@ package storage import ( "context" + "net" "strings" stdlibtime "time" @@ -174,14 +175,10 @@ func IsErr(err, target error, column ...string) bool { } func IsUnexpected(err error) bool { - return !IsErr(err, ErrDuplicate) && - !IsErr(err, ErrRelationNotFound) && - !IsErr(err, ErrNotFound) && - !IsErr(err, ErrCheckFailed) && - !IsErr(err, ErrRelationInUse) && - !IsErr(err, ErrSerializationFailure) && - !IsErr(err, ErrTxAborted) && - !IsErr(err, ErrExclusionViolation) + var pgConnErr *pgconn.PgError + var netOpErr *net.OpError + + return errors.As(err, &pgConnErr) || errors.As(err, &netOpErr) } func parseDBError(err error) error { //nolint:funlen // .