MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / code

Function code

pkg/errors/codes.go:44–58  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

42}
43
44func code(err error) uint32 {
45 switch {
46 case errors.Is(err, context.Canceled):
47 return uint32(codes.Canceled)
48 case errors.Is(err, context.DeadlineExceeded):
49 return uint32(codes.DeadlineExceeded)
50 }
51 if codeErr := (coder)(nil); errors.As(err, &codeErr) {
52 return codeErr.Code()
53 }
54 if ttnErr, ok := From(err); ok {
55 return ttnErr.Code()
56 }
57 return 0
58}
59
60// Code gets the code of an error.
61// If the error doesn't implement codes, Unknown is returned.

Callers 2

CodeFunction · 0.85
HasCodeFunction · 0.85

Calls 4

FromFunction · 0.85
CodeMethod · 0.65
IsMethod · 0.45
AsMethod · 0.45

Tested by

no test coverage detected