Skip to content

Commit

Permalink
Merge pull request #290 from uloamaka/fix/fetch-All-help-center-topics
Browse files Browse the repository at this point in the history
fix: 404 err handling for fetch all help center topics
  • Loading branch information
Micah-Shallom authored Aug 7, 2024
2 parents 07d3404 + 743a4e8 commit c0492f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/helpcenter/helpcenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions services/helpcenter/helpcenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit c0492f3

Please sign in to comment.