Skip to content

Commit

Permalink
Fixed error message and id inclusion in error response
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartendeKruijf committed May 22, 2024
1 parent 888808f commit 60360b7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions routes/reporter/reporter_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (executionInformer *executionInformer) getExecutions(g *gin.Context) {
executions, err := executionInformer.informer.GetExecutions()
if err != nil {
log.Debug("Could not get executions from informer")
error.SendErrorResponse(g, http.StatusInternalServerError, "Could not get executions from informer", "GET /report/", "")
error.SendErrorResponse(g, http.StatusInternalServerError, "Could not get executions from informer", "GET /reporter/", "")
return
}
g.JSON(http.StatusOK, executions)
Expand All @@ -70,21 +70,23 @@ func (executionInformer *executionInformer) getExecutionReport(g *gin.Context) {
uuid, err := uuid.Parse(id)
if err != nil {
log.Debug("Could not parse id parameter for request")
error.SendErrorResponse(g, http.StatusBadRequest, "Could not parse id parameter for request", "GET /report/{id}", "")
error.SendErrorResponse(g, http.StatusBadRequest, "Could not parse id parameter for request", "GET /reporter/"+id, err.Error())
return
}

executionEntry, err := executionInformer.informer.GetExecutionReport(uuid)
if err != nil {
log.Debug("Could not find execution for given id")
error.SendErrorResponse(g, http.StatusBadRequest, "Could not find execution for given ID", "GET /report/{id}", "")
log.Error(err)
error.SendErrorResponse(g, http.StatusBadRequest, "Could not find execution for given ID", "GET /reporter/"+id, "")
return
}

executionEntryParsed, err := parseCachePlaybookEntry(executionEntry)
if err != nil {
log.Debug("Could not parse entry to reporter result model")
error.SendErrorResponse(g, http.StatusInternalServerError, "Could not parse execution report", "GET /report/{id}", "")
log.Error(err)
error.SendErrorResponse(g, http.StatusInternalServerError, "Could not parse execution report", "GET /reporter/"+id, "")
return
}
g.JSON(http.StatusOK, executionEntryParsed)
Expand Down

0 comments on commit 60360b7

Please sign in to comment.