You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2021/05/01 08:35:29 UTC

[GitHub] [incubator-yunikorn-core] manirajv06 commented on a change in pull request #268: YUNIKORN-645. Fixed status code issues, error handling issues etc

manirajv06 commented on a change in pull request #268:
URL: https://github.com/apache/incubator-yunikorn-core/pull/268#discussion_r624450746



##########
File path: pkg/webservice/handlers.go
##########
@@ -211,6 +211,14 @@ func writeHeaders(w http.ResponseWriter) {
 	w.Header().Set("Access-Control-Allow-Headers", "X-Requested-With,Content-Type,Accept,Origin")
 }
 
+func buildJSONErrorResponse(w http.ResponseWriter, detail string, code int) {
+	w.WriteHeader(code)
+	errorInfo := dao.NewYAPIError(nil, code, detail)
+	if jsonErr := json.NewEncoder(w).Encode(errorInfo); jsonErr != nil {

Review comment:
       No, @yangwwei. We are writing the HTTP status code as part of response headers as well. Actual response body has been generated based on the following struct:
   
   	StatusCode  int    `json:"status_code"`
   	Message     string `json:"message"`
   	Description string `json:"description"`
   
   In general, client reads the status code from response headers and takes decision accordingly. I assuming this should be the case even with our UI component.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org