MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / GetPGCodeInternal

Function GetPGCodeInternal

pkg/sql/pgwire/pgerror/pgcode.go:61–77  ·  view source on GitHub ↗

GetPGCodeInternal retrieves a code for the error. It operates by combining the inner (cause) code and the code at the current level, at each level of cause. - at each level: - if there is a candidate code at that level, that is used; - otherwise, it calls computeDefaultCode(). if the function ret

(
	err error, computeDefaultCode func(err error) (code pgcode.Code),
)

Source from the content-addressed store, hash-verified

59// This function should not be used directly. It is only exported
60// for use in testing code. Use GetPGCode() instead.
61func GetPGCodeInternal(
62 err error, computeDefaultCode func(err error) (code pgcode.Code),
63) (code pgcode.Code) {
64 code = pgcode.Uncategorized
65 if c, ok := err.(*withCandidateCode); ok {
66 code = pgcode.MakeCode(c.code)
67 } else if newCode := computeDefaultCode(err); newCode.String() != "" {
68 code = newCode
69 }
70
71 if c := errors.UnwrapOnce(err); c != nil {
72 innerCode := GetPGCodeInternal(c, computeDefaultCode)
73 code = combineCodes(innerCode, code)
74 }
75
76 return code
77}
78
79// ComputeDefaultCode looks at the current error object
80// (not its causes) and returns:

Callers 1

GetPGCodeFunction · 0.85

Calls 3

MakeCodeFunction · 0.92
combineCodesFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…