forked from wrenn/wrenn
fix: map CodeAlreadyExists to HTTP 409 Conflict
Updated the `agentErrToHTTP` switch statement to explicitly catch `connect.CodeAlreadyExists` (as well as `connect.CodeFailedPrecondition`) and return `http.StatusConflict` (409) instead of falling through to the default 502 Bad Gateway.
This commit is contained in:
@ -50,8 +50,12 @@ func agentErrToHTTP(err error) (int, string, string) {
|
|||||||
return http.StatusNotFound, "not_found", err.Error()
|
return http.StatusNotFound, "not_found", err.Error()
|
||||||
case connect.CodeInvalidArgument:
|
case connect.CodeInvalidArgument:
|
||||||
return http.StatusBadRequest, "invalid_request", err.Error()
|
return http.StatusBadRequest, "invalid_request", err.Error()
|
||||||
case connect.CodeFailedPrecondition:
|
case connect.CodeFailedPrecondition, connect.CodeAlreadyExists:
|
||||||
return http.StatusConflict, "conflict", err.Error()
|
return http.StatusConflict, "conflict", err.Error()
|
||||||
|
case connect.CodePermissionDenied:
|
||||||
|
return http.StatusForbidden, "forbidden", err.Error()
|
||||||
|
case connect.CodeUnimplemented:
|
||||||
|
return http.StatusNotImplemented, "agent_error", err.Error()
|
||||||
default:
|
default:
|
||||||
return http.StatusBadGateway, "agent_error", err.Error()
|
return http.StatusBadGateway, "agent_error", err.Error()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user