Merge pull request #234 from tamird/cockroach

api: properly check for errors
This commit is contained in:
Dan Sosedoff 2017-04-30 11:25:39 -05:00 committed by GitHub
commit 0fd652f716

View File

@ -109,11 +109,11 @@ func Connect(c *gin.Context) {
info, err := cl.Info()
if err == nil {
err = setClient(c, cl)
if err != nil {
cl.Close()
c.JSON(400, Error{err.Error()})
return
}
}
if err != nil {
cl.Close()
c.JSON(400, Error{err.Error()})
return
}
c.JSON(200, info.Format()[0])
@ -163,11 +163,11 @@ func SwitchDb(c *gin.Context) {
info, err := cl.Info()
if err == nil {
err = setClient(c, cl)
if err != nil {
cl.Close()
c.JSON(400, Error{err.Error()})
return
}
}
if err != nil {
cl.Close()
c.JSON(400, Error{err.Error()})
return
}
conn.Close()