...
1
18
19 package codes
20
21 import (
22 "strconv"
23
24 "google.golang.org/grpc/internal"
25 )
26
27 func init() {
28 internal.CanonicalString = canonicalString
29 }
30
31 func (c Code) String() string {
32 switch c {
33 case OK:
34 return "OK"
35 case Canceled:
36 return "Canceled"
37 case Unknown:
38 return "Unknown"
39 case InvalidArgument:
40 return "InvalidArgument"
41 case DeadlineExceeded:
42 return "DeadlineExceeded"
43 case NotFound:
44 return "NotFound"
45 case AlreadyExists:
46 return "AlreadyExists"
47 case PermissionDenied:
48 return "PermissionDenied"
49 case ResourceExhausted:
50 return "ResourceExhausted"
51 case FailedPrecondition:
52 return "FailedPrecondition"
53 case Aborted:
54 return "Aborted"
55 case OutOfRange:
56 return "OutOfRange"
57 case Unimplemented:
58 return "Unimplemented"
59 case Internal:
60 return "Internal"
61 case Unavailable:
62 return "Unavailable"
63 case DataLoss:
64 return "DataLoss"
65 case Unauthenticated:
66 return "Unauthenticated"
67 default:
68 return "Code(" + strconv.FormatInt(int64(c), 10) + ")"
69 }
70 }
71
72 func canonicalString(c Code) string {
73 switch c {
74 case OK:
75 return "OK"
76 case Canceled:
77 return "CANCELLED"
78 case Unknown:
79 return "UNKNOWN"
80 case InvalidArgument:
81 return "INVALID_ARGUMENT"
82 case DeadlineExceeded:
83 return "DEADLINE_EXCEEDED"
84 case NotFound:
85 return "NOT_FOUND"
86 case AlreadyExists:
87 return "ALREADY_EXISTS"
88 case PermissionDenied:
89 return "PERMISSION_DENIED"
90 case ResourceExhausted:
91 return "RESOURCE_EXHAUSTED"
92 case FailedPrecondition:
93 return "FAILED_PRECONDITION"
94 case Aborted:
95 return "ABORTED"
96 case OutOfRange:
97 return "OUT_OF_RANGE"
98 case Unimplemented:
99 return "UNIMPLEMENTED"
100 case Internal:
101 return "INTERNAL"
102 case Unavailable:
103 return "UNAVAILABLE"
104 case DataLoss:
105 return "DATA_LOSS"
106 case Unauthenticated:
107 return "UNAUTHENTICATED"
108 default:
109 return "CODE(" + strconv.FormatInt(int64(c), 10) + ")"
110 }
111 }
112
View as plain text