Skip to content

Commit e114028

Browse files
committed
review comments
1 parent 8cc6f73 commit e114028

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ func (handler *PipelineConfigRestHandlerImpl) UpdateCiTemplate(w http.ResponseWr
178178

179179
createResp, err := handler.pipelineBuilder.UpdateCiTemplate(&configRequest)
180180
if err != nil {
181-
handler.Logger.Errorw("service err", "err", err, "context", "UpdateCiTemplate", "data", configRequest)
182-
common.WriteJsonResp(w, err, createResp, http.StatusInternalServerError)
181+
handler.Logger.Errorw("service err, UpdateCiTemplate", "UpdateCiTemplate", configRequest, "err", err)
182+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
183183
return
184184
}
185185
common.WriteJsonResp(w, nil, createResp, http.StatusOK)
@@ -229,7 +229,7 @@ func (handler *PipelineConfigRestHandlerImpl) UpdateBranchCiPipelinesWithRegex(w
229229
//if include/exclude configured showAll will include excluded materials also in list, if not configured it will ignore this flag
230230
resp, err := handler.ciHandler.FetchMaterialsByPipelineId(patchRequest.Id, false)
231231
if err != nil {
232-
handler.Logger.Errorw("service err", "err", err, "context", "FetchMaterials", "data", map[string]interface{}{"pipelineId": patchRequest.Id})
232+
handler.Logger.Errorw("service err, FetchMaterials", "pipelineId", patchRequest.Id, "err", err)
233233
common.WriteJsonResp(w, err, resp, http.StatusInternalServerError)
234234
return
235235
}
@@ -273,7 +273,7 @@ func (handler *PipelineConfigRestHandlerImpl) parseBulkSourceChangeRequest(w htt
273273

274274
err = handler.validator.Struct(patchRequest)
275275
if err != nil {
276-
handler.Logger.Errorw("request err, BulkPatchCiPipeline", "err", err, "BulkPatchCiPipeline", patchRequest)
276+
handler.Logger.Errorw("request err, BulkPatchCiPipeline", "BulkPatchCiPipeline", patchRequest, "err", err)
277277
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
278278
return nil, 0, err
279279
}
@@ -346,7 +346,7 @@ func (handler *PipelineConfigRestHandlerImpl) PatchCiMaterialSourceWithAppIdsAnd
346346
// Here passing the checkAppSpecificAccess func to check RBAC
347347
bulkPatchResponse, err := handler.pipelineBuilder.BulkPatchCiMaterialSource(bulkPatchRequest, userId, token, handler.checkAppSpecificAccess)
348348
if err != nil {
349-
handler.Logger.Errorw("service err, BulkPatchCiPipelines", "err", err, "BulkPatchCiPipelines", bulkPatchRequest)
349+
handler.Logger.Errorw("service err, BulkPatchCiPipelines", "BulkPatchCiPipelines", bulkPatchRequest, "err", err)
350350
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
351351
return
352352
}
@@ -445,7 +445,7 @@ func (handler *PipelineConfigRestHandlerImpl) PatchCiPipelines(w http.ResponseWr
445445
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
446446
return
447447
}
448-
handler.Logger.Errorw("service err, PatchCiPipelines", "err", err, "PatchCiPipelines", patchRequest)
448+
handler.Logger.Errorw("service err, PatchCiPipelines", "PatchCiPipelines", patchRequest, "err", err)
449449
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
450450
return
451451
}
@@ -541,7 +541,7 @@ func (handler *PipelineConfigRestHandlerImpl) GetCiPipeline(w http.ResponseWrite
541541

542542
ciConf, err := handler.pipelineBuilder.GetCiPipelineRespResolved(appId)
543543
if err != nil {
544-
handler.Logger.Errorw("service err", "err", err, "context", "GetCiPipelineRespResolved", "data", map[string]interface{}{"appId": appId})
544+
handler.Logger.Errorw("service err, GetCiPipelineRespResolved", "appId", appId, "err", err)
545545
common.WriteJsonResp(w, err, ciConf, http.StatusInternalServerError)
546546
return
547547
}
@@ -563,8 +563,8 @@ func (handler *PipelineConfigRestHandlerImpl) GetExternalCi(w http.ResponseWrite
563563

564564
ciConf, err := handler.pipelineBuilder.GetExternalCi(appId)
565565
if err != nil {
566-
handler.Logger.Errorw("service err", "err", err, "context", "GetExternalCi", "data", map[string]interface{}{"appId": appId})
567-
common.WriteJsonResp(w, err, ciConf, http.StatusInternalServerError)
566+
handler.Logger.Errorw("service err, GetExternalCi", "err", err, "appId", appId)
567+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
568568
return
569569
}
570570
common.WriteJsonResp(w, nil, ciConf, http.StatusOK)
@@ -590,8 +590,8 @@ func (handler *PipelineConfigRestHandlerImpl) GetExternalCiById(w http.ResponseW
590590

591591
ciConf, err := handler.pipelineBuilder.GetExternalCiById(appId, externalCiId)
592592
if err != nil {
593-
handler.Logger.Errorw("service err", "err", err, "context", "GetExternalCiById", "data", map[string]interface{}{"appId": appId, "externalCiId": externalCiId})
594-
common.WriteJsonResp(w, err, ciConf, http.StatusInternalServerError)
593+
handler.Logger.Errorw("service err, GetExternalCiById", "err", err, "appId", appId)
594+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
595595
return
596596
}
597597
common.WriteJsonResp(w, nil, ciConf, http.StatusOK)
@@ -794,7 +794,7 @@ func (handler *PipelineConfigRestHandlerImpl) FetchMaterialsByMaterialId(w http.
794794

795795
resp, err := handler.ciHandler.FetchMaterialsByPipelineIdAndGitMaterialId(pipelineId, gitMaterialId, showAll)
796796
if err != nil {
797-
handler.Logger.Errorw("service err", "err", err, "context", "FetchMaterialsByMaterialId", "data", map[string]interface{}{"pipelineId": pipelineId, "gitMaterialId": gitMaterialId})
797+
handler.Logger.Errorw("service err, FetchMaterials", "err", err, "pipelineId", pipelineId)
798798
common.WriteJsonResp(w, err, resp, http.StatusInternalServerError)
799799
return
800800
}
@@ -830,7 +830,7 @@ func (handler *PipelineConfigRestHandlerImpl) RefreshMaterials(w http.ResponseWr
830830

831831
resp, err := handler.ciHandler.RefreshMaterialByCiPipelineMaterialId(material.Id)
832832
if err != nil {
833-
handler.Logger.Errorw("service err", "err", err, "context", "RefreshMaterials", "data", map[string]interface{}{"gitMaterialId": gitMaterialId})
833+
handler.Logger.Errorw("service err, RefreshMaterials", "err", err, "gitMaterialId", gitMaterialId)
834834
common.WriteJsonResp(w, err, resp, http.StatusInternalServerError)
835835
return
836836
}
@@ -872,9 +872,13 @@ func (handler *PipelineConfigRestHandlerImpl) GetCiPipelineMin(w http.ResponseWr
872872

873873
ciPipelines, err := handler.pipelineBuilder.GetCiPipelineMin(appId, envIds)
874874
if err != nil {
875-
handler.Logger.Errorw("service err", "err", err, "context", "GetCiPipelineMin", "data", map[string]interface{}{"appId": appId})
876-
common.WriteJsonResp(w, err, ciPipelines, http.StatusInternalServerError)
877-
return
875+
handler.Logger.Errorw("service err, GetCiPipelineMin", "err", err, "appId", appId)
876+
if util.IsErrNoRows(err) {
877+
err = &util.ApiError{Code: "404", HttpStatusCode: http.StatusNotFound, UserMessage: "no data found"}
878+
common.WriteJsonResp(w, err, nil, http.StatusOK)
879+
} else {
880+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
881+
}
878882
}
879883
common.WriteJsonResp(w, nil, ciPipelines, http.StatusOK)
880884
}
@@ -972,7 +976,7 @@ func (handler *PipelineConfigRestHandlerImpl) GetHistoricBuildLogs(w http.Respon
972976

973977
resp, err := handler.ciHandler.GetHistoricBuildLogs(workflowId, nil)
974978
if err != nil {
975-
handler.Logger.Errorw("service err", "err", err, "context", "GetHistoricBuildLogs", "data", map[string]interface{}{"pipelineId": pipelineId, "workflowId": workflowId})
979+
handler.Logger.Errorw("service err, GetHistoricBuildLogs", "err", err, "pipelineId", pipelineId, "workflowId", workflowId)
976980
common.WriteJsonResp(w, err, resp, http.StatusInternalServerError)
977981
return
978982
}

0 commit comments

Comments
 (0)