Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 404 err handling for fetch all help center topics #290

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading