@@ -2,7 +2,6 @@ package main
2
2
3
3
import (
4
4
"encoding/json"
5
- "log"
6
5
"net/http"
7
6
"time"
8
7
@@ -13,14 +12,13 @@ import (
13
12
func (cfg * apiConfig ) handlerNotesGet (w http.ResponseWriter , r * http.Request , user database.User ) {
14
13
posts , err := cfg .DB .GetNotesForUser (r .Context (), user .ID )
15
14
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 )
17
16
return
18
17
}
19
18
20
19
postsResp , err := databasePostsToPosts (posts )
21
20
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 )
24
22
return
25
23
}
26
24
@@ -35,7 +33,7 @@ func (cfg *apiConfig) handlerNotesCreate(w http.ResponseWriter, r *http.Request,
35
33
params := parameters {}
36
34
err := decoder .Decode (& params )
37
35
if err != nil {
38
- respondWithError (w , http .StatusInternalServerError , "Couldn't decode parameters" )
36
+ respondWithError (w , http .StatusInternalServerError , "Couldn't decode parameters" , err )
39
37
return
40
38
}
41
39
@@ -48,20 +46,19 @@ func (cfg *apiConfig) handlerNotesCreate(w http.ResponseWriter, r *http.Request,
48
46
UserID : user .ID ,
49
47
})
50
48
if err != nil {
51
- respondWithError (w , http .StatusInternalServerError , "Couldn't create note" )
49
+ respondWithError (w , http .StatusInternalServerError , "Couldn't create note" , err )
52
50
return
53
51
}
54
52
55
53
note , err := cfg .DB .GetNote (r .Context (), id )
56
54
if err != nil {
57
- respondWithError (w , http .StatusNotFound , "Couldn't get note" )
55
+ respondWithError (w , http .StatusNotFound , "Couldn't get note" , err )
58
56
return
59
57
}
60
58
61
59
noteResp , err := databaseNoteToNote (note )
62
60
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 )
65
62
return
66
63
}
67
64
0 commit comments