MCPcopy Create free account
hub / github.com/pydio/cells / CodeFromHTTPStatus

Function CodeFromHTTPStatus

common/middleware/errors-grpc.go:160–189  ·  view source on GitHub ↗

CodeFromHTTPStatus converts an HTTP response status into the corresponding gRPC error code.

(status int)

Source from the content-addressed store, hash-verified

158// CodeFromHTTPStatus converts an HTTP response status into the corresponding
159// gRPC error code.
160func CodeFromHTTPStatus(status int) codes.Code {
161 switch status {
162 case http.StatusOK:
163 return codes.OK
164 case http.StatusTooManyRequests:
165 return codes.ResourceExhausted
166 case http.StatusRequestTimeout:
167 return codes.DeadlineExceeded
168 case http.StatusInternalServerError:
169 return codes.Unknown
170 case http.StatusBadRequest:
171 return codes.InvalidArgument
172 case http.StatusNotFound:
173 return codes.NotFound
174 case http.StatusConflict:
175 return codes.AlreadyExists
176 case http.StatusForbidden:
177 return codes.PermissionDenied
178 case http.StatusUnauthorized:
179 return codes.Unauthenticated
180 case http.StatusPreconditionFailed:
181 return codes.FailedPrecondition
182 case http.StatusNotImplemented:
183 return codes.Unimplemented
184 case http.StatusServiceUnavailable:
185 return codes.Unavailable
186 default:
187 return codes.Code(uint32(status))
188 }
189}
190
191func ToGRPC(er error) error {
192 if er == nil {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…