MCPcopy Index your code
hub / github.com/cockroachdb/errors / getTypeDetails

Function getTypeDetails

errbase/encode.go:218–252  ·  view source on GitHub ↗
(
	err error, onlyFamily bool,
)

Source from the content-addressed store, hash-verified

216}
217
218func getTypeDetails(
219 err error, onlyFamily bool,
220) (origTypeName string, typeKeyFamily string, typeKeyExtension string) {
221 // If we have received an error of type not known locally,
222 // we still know its type name. Return that.
223 switch t := err.(type) {
224 case *opaqueLeaf:
225 return t.details.OriginalTypeName, t.details.ErrorTypeMark.FamilyName, t.details.ErrorTypeMark.Extension
226 case *opaqueLeafCauses:
227 return t.details.OriginalTypeName, t.details.ErrorTypeMark.FamilyName, t.details.ErrorTypeMark.Extension
228 case *opaqueWrapper:
229 return t.details.OriginalTypeName, t.details.ErrorTypeMark.FamilyName, t.details.ErrorTypeMark.Extension
230 }
231
232 // Compute the full error name, for reporting and printing details.
233 tn := getFullTypeName(err)
234 // Compute a family name, used to find decoders and to compare error identities.
235 fm := tn
236 if prevKey, ok := backwardRegistry[TypeKey(tn)]; ok {
237 fm = string(prevKey)
238 }
239
240 if onlyFamily {
241 return tn, fm, ""
242 }
243
244 // If the error has an extra type marker, add it.
245 // This is not used by the base functionality but
246 // is hooked into by the barrier subsystem.
247 var em string
248 if tm, ok := err.(TypeKeyMarker); ok {
249 em = tm.ErrorKeyMarker()
250 }
251 return tn, fm, em
252}
253
254// TypeKeyMarker can be implemented by errors that wish to extend
255// their type name as seen by GetTypeKey().

Callers 5

GetSafeDetailsFunction · 0.85
encodeLeafFunction · 0.85
encodeWrapperFunction · 0.85
GetTypeKeyFunction · 0.85
GetTypeMarkFunction · 0.85

Calls 3

getFullTypeNameFunction · 0.85
TypeKeyTypeAlias · 0.85
ErrorKeyMarkerMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…