diff --git a/pkg/controller/helpcenter/helpcenter.go b/pkg/controller/helpcenter/helpcenter.go index ccbc4573..c6e1fb7b 100644 --- a/pkg/controller/helpcenter/helpcenter.go +++ b/pkg/controller/helpcenter/helpcenter.go @@ -76,10 +76,10 @@ func (base *Controller) FetchAllTopics(c *gin.Context) { topics, paginationResponse, err := service.GetPaginatedTopics(c, base.Db.Postgresql) if err != nil { if err == gorm.ErrRecordNotFound { - rd := utility.BuildErrorResponse(http.StatusNotFound, "error", "No Job post not found", err, nil) + rd := utility.BuildErrorResponse(http.StatusNotFound, "error", "Topics not found", err, nil) c.JSON(http.StatusNotFound, rd) } else { - rd := utility.BuildErrorResponse(http.StatusInternalServerError, "error", "Failed to fetch job post", err, nil) + rd := utility.BuildErrorResponse(http.StatusInternalServerError, "error", "Failed to fetch topics", err, nil) c.JSON(http.StatusInternalServerError, rd) } return diff --git a/services/helpcenter/helpcenter.go b/services/helpcenter/helpcenter.go index 0b072951..8f41f185 100644 --- a/services/helpcenter/helpcenter.go +++ b/services/helpcenter/helpcenter.go @@ -40,6 +40,11 @@ func GetPaginatedTopics(c *gin.Context, db *gorm.DB) ([]HelpCntSummary, postgres if err != nil { return nil, paginationResponse, err } + + if len(helpCnts) == 0 { + return nil, paginationResponse, gorm.ErrRecordNotFound + } + var topicSummaries []HelpCntSummary for _, Hlp := range helpCnts { summary := HelpCntSummary{