Skip to content

Commit c24229a

Browse files
committed
Add REQUEST_TIMEOUT handler error type
1 parent 2a65a7d commit c24229a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

nexus/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ const (
180180
// The requested resource could not be found but may be available in the future. Clients should not retry
181181
// this request unless advised otherwise.
182182
HandlerErrorTypeNotFound HandlerErrorType = "NOT_FOUND"
183+
// Returned by the server to when it has given up handling a request. The may occur by enforcing a client
184+
// provided `Request-Timeout` or for any arbitrary reason such as enforcing some configurable limit. Subsequent
185+
// requests by the client are permissible.
186+
HandlerErrorTypeRequestTimeout HandlerErrorType = "REQUEST_TIMEOUT"
183187
// The request could not be made due to a conflict. The may happen when trying to create an operation that
184188
// has already been started. Clients should not retry this request unless advised otherwise.
185189
HandlerErrorTypeConflict HandlerErrorType = "CONFLICT"

nexus/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ func httpStatusCodeToHandlerErrorType(response *http.Response) (HandlerErrorType
460460
switch response.StatusCode {
461461
case http.StatusBadRequest:
462462
return HandlerErrorTypeBadRequest, nil
463+
case http.StatusRequestTimeout:
464+
return HandlerErrorTypeRequestTimeout, nil
463465
case http.StatusConflict:
464466
return HandlerErrorTypeConflict, nil
465467
case http.StatusUnauthorized:

nexus/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ func (h *baseHTTPHandler) writeFailure(writer http.ResponseWriter, err error) {
308308
switch handlerError.Type {
309309
case HandlerErrorTypeBadRequest:
310310
statusCode = http.StatusBadRequest
311+
case HandlerErrorTypeRequestTimeout:
312+
statusCode = http.StatusRequestTimeout
311313
case HandlerErrorTypeConflict:
312314
statusCode = http.StatusConflict
313315
case HandlerErrorTypeUnauthenticated:

0 commit comments

Comments
 (0)