From 3da08a1f54d39ac172323c4cdeedd35f98b2b5e1 Mon Sep 17 00:00:00 2001 From: Alexandre Tuleu Date: Mon, 25 Jan 2016 20:23:23 +0100 Subject: [PATCH] Avoid some panic Idiomatic return after writing an error response --- router.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/router.go b/router.go index b83128d..c55e222 100644 --- a/router.go +++ b/router.go @@ -53,6 +53,7 @@ func (a *appData) buildRouter() http.Handler { err = enc.Encode(albums) if err != nil { narco.Error(ctx, w, err, http.StatusInternalServerError) + return } }))) @@ -73,6 +74,7 @@ func (a *appData) buildRouter() http.Handler { albumUnsafe, err := a.db.Get(AlbumID(id)) if err != nil { narco.Error(ctx, w, err, http.StatusInternalServerError) + return } album := *albumUnsafe @@ -81,6 +83,7 @@ func (a *appData) buildRouter() http.Handler { enc := json.NewEncoder(w) if err := enc.Encode(album); err != nil { narco.Error(ctx, w, err, http.StatusInternalServerError) + return } })))