MCPcopy Create free account
hub / github.com/Permify/permify / GetStatus

Function GetStatus

internal/servers/error.go:11–35  ·  view source on GitHub ↗

GetStatus - Get status code and message from error

(err error)

Source from the content-addressed store, hash-verified

9
10// GetStatus - Get status code and message from error
11func GetStatus(err error) codes.Code {
12 s, ok := status.FromError(err)
13 if ok {
14 // This was a custom error, so return its code directly
15 return s.Code()
16 }
17
18 // If this wasn't a custom error, continue with your existing logic...
19 code, ok := base.ErrorCode_value[err.Error()]
20 if !ok {
21 return codes.Internal
22 }
23 switch {
24 case code > 999 && code < 1999:
25 return codes.Unauthenticated
26 case code > 1999 && code < 2999:
27 return codes.InvalidArgument
28 case code > 3999 && code < 4999:
29 return codes.NotFound
30 case code > 4999 && code < 5999:
31 return codes.Internal
32 default:
33 return codes.Internal
34 }
35}

Callers 15

WatchMethod · 0.85
WriteMethod · 0.85
ReadMethod · 0.85
DeleteMethod · 0.85
CreateMethod · 0.85
DeleteMethod · 0.85
ListMethod · 0.85
ReadRelationshipsMethod · 0.85
ReadAttributesMethod · 0.85
WriteMethod · 0.85
WriteRelationshipsMethod · 0.85
DeleteMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected