MCPcopy Create free account
hub / github.com/dataddo/pgq / isErrorCode

Function isErrorCode

errors.go:33–43  ·  view source on GitHub ↗

var ( _ pgError = (*pgconn.PgError)(nil) _ pgError = (*pq.Error)(nil) _ legacyPGError = (*pq.Error)(nil) )

(err error, codes ...string)

Source from the content-addressed store, hash-verified

31//)
32
33func isErrorCode(err error, codes ...string) bool {
34 var pgErr pgError
35 if ok := errors.As(err, &pgErr); !ok {
36 var legacyErr legacyPGError
37 if ok := errors.As(err, &legacyErr); !ok {
38 return false
39 }
40 return slices.Contains(codes, legacyErr.Get('C'))
41 }
42 return slices.Contains(codes, pgErr.SQLState())
43}

Callers 3

tryConsumeMessagesMethod · 0.85
parseRowMethod · 0.85
Test_isErrorCodeFunction · 0.85

Calls 2

GetMethod · 0.95
SQLStateMethod · 0.95

Tested by 1

Test_isErrorCodeFunction · 0.68