File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments