From a22cfe992fbadd3662b7145fda0d55615339c89c Mon Sep 17 00:00:00 2001 From: Dario Ernst Date: Mon, 31 Jul 2017 19:57:27 +0200 Subject: [PATCH] Add error handling for db lookup --- server/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/main.go b/server/main.go index e550ee1..fe617cc 100644 --- a/server/main.go +++ b/server/main.go @@ -54,6 +54,10 @@ func getToken(w http.ResponseWriter, r *http.Request) error { log.Println("getToken got name:", userInput.Name, "pass:", userInput.Pass) db.First(&userRecord) + if db.Error != nil { + log.Println("db finding user had error",err) + return ehttp.NewErrorf(http.StatusInternalServerError, "database lookup error") + } if userRecord.Name == userInput.Name && userRecord.Pass == userInput.Pass { token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{