Skip to content

Commit a3ac6e7

Browse files
committed
feat: idea not found
1 parent d00f024 commit a3ac6e7

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

pkg/controller/ideas.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,31 @@ func GetIdea(c echo.Context) error {
147147
if !ok || !user.TeamID.Valid {
148148
return c.JSON(http.StatusForbidden, &models.Response{
149149
Status: "fail",
150-
Message: "User does not belong to any team",
150+
Message: "Please join a team or create one",
151151
})
152152
}
153153

154154
ideas, err := utils.Queries.GetIdeaByTeamID(context.Background(), user.TeamID.UUID)
155155
if err != nil {
156+
if errors.Is(err, pgx.ErrNoRows) {
157+
return c.JSON(http.StatusNotFound, &models.Response{
158+
Status: "success",
159+
Message: "Idea not found",
160+
})
161+
}
162+
163+
logger.Errorf(logger.InternalError, err.Error())
156164
return c.JSON(http.StatusInternalServerError, &models.Response{
157165
Status: "fail",
158-
Message: err.Error(),
166+
Message: "some error occurred",
159167
})
160168
}
161169

162170
return c.JSON(http.StatusOK, &models.Response{
163-
Status: "success",
171+
Status: "success",
172+
Message: "ideas fetched successfully",
164173
Data: map[string]interface{}{
165-
"message": "Ideas fetched successfully",
166-
"ideas": ideas,
174+
"ideas": ideas,
167175
},
168176
})
169177
}

pkg/utils/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type cfg struct {
3030
RepoName string `env:"REPO_NAME,notEmpty"`
3131
Recipients string `env:"RECIPIENETS"`
3232
CookieSecure bool `env:"SECURE" envDefault:"false"`
33-
Domain string `env:"DOMAIN" envDefault:".codechefvit.com"`
33+
Domain string `env:"DOMAIN" envDefault:".codechefvit.com"`
3434
GithubPAT string `env:"GITHUB_PAT"`
3535
}
3636

@@ -43,6 +43,6 @@ func init() {
4343

4444
if err := env.Parse(&Config); err != nil {
4545
fmt.Printf("%+v", err)
46-
panic(err);
46+
panic(err)
4747
}
4848
}

0 commit comments

Comments
 (0)