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

Function ComputeDefaultCode

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

ComputeDefaultCode looks at the current error object (not its causes) and returns: - the existing code for Error instances - SerializationFailure for roachpb retry errors that can be reported to clients - StatementCompletionUnknown for ambiguous commit errors - InternalError for assertion failures -

(err error)

Source from the content-addressed store, hash-verified

87// It is not meant to be used directly - it is only exported
88// for use by test code. Use GetPGCode() instead.
89func ComputeDefaultCode(err error) pgcode.Code {
90 switch e := err.(type) {
91 // If there was already a pgcode in the cause, use that.
92 case *Error:
93 return pgcode.MakeCode(e.Code)
94 // Special roachpb errors get a special code.
95 case ClientVisibleRetryError:
96 return pgcode.SerializationFailure
97 case ClientVisibleAmbiguousError:
98 return pgcode.StatementCompletionUnknown
99 }
100
101 if errors.IsAssertionFailure(err) {
102 return pgcode.Internal
103 }
104 if errors.IsUnimplementedError(err) {
105 return pgcode.FeatureNotSupported
106 }
107 return pgcode.Code{}
108}
109
110// ClientVisibleRetryError mirrors kvpb.ClientVisibleRetryError but
111// is defined here to avoid an import cycle.

Callers

nothing calls this directly

Calls 1

MakeCodeFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…