socialnetworknews-api

git clone git://archive.git.mtrnord.blog/SocialNetworkNews/socialnetworknews-api.git
Log | Files | Refs | LICENSE

commit d30bb9eb6e7b0fb19df0cfec7245cb5132048b69
parent 63cf1e0ed815df18e86d9a9e039adef249b28bdf
Author: MTRNord <mtrnord1@gmail.com>
Date:   Tue,  3 Apr 2018 18:48:34 +0200

Add some more context to the errors

Diffstat:
Mapi/webserver.go | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/api/webserver.go b/api/webserver.go @@ -59,7 +59,7 @@ type Paper struct { UUID string `json:"uuid,omitempty"` Description string `json:"description,omitempty"` PaperImage string `json:"paper_image,omitempty"` - Author `json:"author,omitempty"` + Author Author `json:"author,omitempty"` } type Author struct { @@ -87,14 +87,16 @@ func Papers(w http.ResponseWriter, r *http.Request) { var t []Paper err := decoder.Decode(&t) if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + decodeErr := errors.WithMessage(err, "Decoding") + http.Error(w, decodeErr.Error(), http.StatusInternalServerError) return } defer r.Body.Close() papers, err := addPapers(t) if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + addErr := errors.WithMessage(err, "Adding") + http.Error(w, addErr.Error(), http.StatusInternalServerError) return } data = papers