19
19
// Package codes defines the canonical error codes used by gRPC. It is
20
20
// consistent across various languages.
21
21
package codes // import "google.golang.org/grpc/codes"
22
+
22
23
import (
23
24
"fmt"
24
25
)
@@ -33,9 +34,9 @@ const (
33
34
// Canceled indicates the operation was canceled (typically by the caller).
34
35
Canceled Code = 1
35
36
36
- // Unknown error. An example of where this error may be returned is
37
+ // Unknown error. An example of where this error may be returned is
37
38
// if a Status value received from another address space belongs to
38
- // an error-space that is not known in this address space. Also
39
+ // an error-space that is not known in this address space. Also
39
40
// errors raised by APIs that do not return enough error information
40
41
// may be converted to this error.
41
42
Unknown Code = 2
@@ -64,15 +65,11 @@ const (
64
65
// PermissionDenied indicates the caller does not have permission to
65
66
// execute the specified operation. It must not be used for rejections
66
67
// caused by exhausting some resource (use ResourceExhausted
67
- // instead for those errors). It must not be
68
+ // instead for those errors). It must not be
68
69
// used if the caller cannot be identified (use Unauthenticated
69
70
// instead for those errors).
70
71
PermissionDenied Code = 7
71
72
72
- // Unauthenticated indicates the request does not have valid
73
- // authentication credentials for the operation.
74
- Unauthenticated Code = 16
75
-
76
73
// ResourceExhausted indicates some resource has been exhausted, perhaps
77
74
// a per-user quota, or perhaps the entire file system is out of space.
78
75
ResourceExhausted Code = 8
@@ -88,7 +85,7 @@ const (
88
85
// (b) Use Aborted if the client should retry at a higher-level
89
86
// (e.g., restarting a read-modify-write sequence).
90
87
// (c) Use FailedPrecondition if the client should not retry until
91
- // the system state has been explicitly fixed. E.g., if an "rmdir"
88
+ // the system state has been explicitly fixed. E.g., if an "rmdir"
92
89
// fails because the directory is non-empty, FailedPrecondition
93
90
// should be returned since the client should not retry unless
94
91
// they have first fixed up the directory by deleting files from it.
@@ -117,7 +114,7 @@ const (
117
114
// file size.
118
115
//
119
116
// There is a fair bit of overlap between FailedPrecondition and
120
- // OutOfRange. We recommend using OutOfRange (the more specific
117
+ // OutOfRange. We recommend using OutOfRange (the more specific
121
118
// error) when it applies so that callers who are iterating through
122
119
// a space can easily look for an OutOfRange error to detect when
123
120
// they are done.
@@ -127,8 +124,8 @@ const (
127
124
// supported/enabled in this service.
128
125
Unimplemented Code = 12
129
126
130
- // Internal errors. Means some invariants expected by underlying
131
- // system has been broken. If you see one of these errors,
127
+ // Internal errors. Means some invariants expected by underlying
128
+ // system has been broken. If you see one of these errors,
132
129
// something is very broken.
133
130
Internal Code = 13
134
131
@@ -142,6 +139,10 @@ const (
142
139
143
140
// DataLoss indicates unrecoverable data loss or corruption.
144
141
DataLoss Code = 15
142
+
143
+ // Unauthenticated indicates the request does not have valid
144
+ // authentication credentials for the operation.
145
+ Unauthenticated Code = 16
145
146
)
146
147
147
148
var strToCode = map [string ]Code {
0 commit comments