@@ -2,7 +2,6 @@ package main
22
33import (
44 "encoding/json"
5- "log"
65 "net/http"
76 "time"
87
@@ -13,14 +12,13 @@ import (
1312func (cfg * apiConfig ) handlerNotesGet (w http.ResponseWriter , r * http.Request , user database.User ) {
1413 posts , err := cfg .DB .GetNotesForUser (r .Context (), user .ID )
1514 if err != nil {
16- respondWithError (w , http .StatusInternalServerError , "Couldn't get posts for user" )
15+ respondWithError (w , http .StatusInternalServerError , "Couldn't get posts for user" , err )
1716 return
1817 }
1918
2019 postsResp , err := databasePostsToPosts (posts )
2120 if err != nil {
22- log .Println (err )
23- respondWithError (w , http .StatusInternalServerError , "Couldn't convert posts" )
21+ respondWithError (w , http .StatusInternalServerError , "Couldn't convert posts" , err )
2422 return
2523 }
2624
@@ -35,7 +33,7 @@ func (cfg *apiConfig) handlerNotesCreate(w http.ResponseWriter, r *http.Request,
3533 params := parameters {}
3634 err := decoder .Decode (& params )
3735 if err != nil {
38- respondWithError (w , http .StatusInternalServerError , "Couldn't decode parameters" )
36+ respondWithError (w , http .StatusInternalServerError , "Couldn't decode parameters" , err )
3937 return
4038 }
4139
@@ -48,20 +46,19 @@ func (cfg *apiConfig) handlerNotesCreate(w http.ResponseWriter, r *http.Request,
4846 UserID : user .ID ,
4947 })
5048 if err != nil {
51- respondWithError (w , http .StatusInternalServerError , "Couldn't create note" )
49+ respondWithError (w , http .StatusInternalServerError , "Couldn't create note" , err )
5250 return
5351 }
5452
5553 note , err := cfg .DB .GetNote (r .Context (), id )
5654 if err != nil {
57- respondWithError (w , http .StatusNotFound , "Couldn't get note" )
55+ respondWithError (w , http .StatusNotFound , "Couldn't get note" , err )
5856 return
5957 }
6058
6159 noteResp , err := databaseNoteToNote (note )
6260 if err != nil {
63- log .Println (err )
64- respondWithError (w , http .StatusInternalServerError , "Couldn't convert note" )
61+ respondWithError (w , http .StatusInternalServerError , "Couldn't convert note" , err )
6562 return
6663 }
6764
0 commit comments